Prerequisites
Before you begin, make sure you have the following installed:- Node.js 18+ - Download Node.js
- pnpm - Install with
npm install -g pnpm - PostgreSQL - Local instance or remote database
- Stripe Account - Sign up for free
- Stripe CLI - Install Stripe CLI
Installation
Install dependencies
Install the project dependencies using pnpm:
The project uses pnpm for package management. If you prefer npm or yarn, you can use those instead, but pnpm is recommended for faster installs.
Set up environment variables
Run the database setup script to create your This interactive script will prompt you for:
.env file:- PostgreSQL connection URL
- Stripe secret key
- Stripe webhook secret
- Base URL (defaults to
http://localhost:3000) - Auth secret (auto-generated)
Manual .env setup
Manual .env setup
If you prefer to set up your Generate a secure
.env file manually, create a .env file in the root directory:AUTH_SECRET with:Set up the database
Run the database migrations to create the necessary tables:Then seed the database with sample data:This creates:
- A test user with email
[email protected]and passwordadmin123 - A test team named “Test Team”
- Sample Stripe products for testing
Configure Stripe
Log in to the Stripe CLI:In a separate terminal, start listening for webhooks:Copy the webhook signing secret (starts with
whsec_) and add it to your .env file:Start the development server
Start the Next.js development server:Open http://localhost:3000 in your browser to see your application running.
Testing the Application
Sign In with Test Account
- Navigate to http://localhost:3000/sign-in
- Use the seeded test credentials:
- Email:
[email protected] - Password:
admin123
- Email:
- You’ll be redirected to the dashboard
Create a New Account
- Navigate to http://localhost:3000/sign-up
- Fill in the registration form
- You’ll be automatically signed in and redirected to the dashboard
Test Stripe Payments
To test the subscription flow:- Go to the pricing page: http://localhost:3000/pricing
- Click “Subscribe” on any plan
- Use Stripe’s test card numbers:
All subscriptions include a 14-day free trial by default. You can modify this in
lib/payments/stripe.ts:42.Available Scripts
The project includes several useful npm scripts:Start the Next.js development server with Turbopack
Build the application for production
Start the production server
Interactive setup script to create your
.env fileGenerate Drizzle ORM migrations from schema changes
Run database migrations
Seed the database with sample data
Open Drizzle Studio to explore your database
Project Structure
Next Steps
Now that you have the application running, explore the core features:Authentication
Learn how JWT-based authentication works
Team Management
Understand multi-tenancy and RBAC
Stripe Integration
Explore subscription and billing features
Database Schema
View the complete database schema
Troubleshooting
Database connection failed
Database connection failed
Make sure your PostgreSQL database is running and the
POSTGRES_URL in your .env file is correct.If using Docker, start PostgreSQL with:Stripe webhooks not working
Stripe webhooks not working
Make sure the Stripe CLI is running:Verify that the
STRIPE_WEBHOOK_SECRET in your .env file matches the webhook signing secret from the Stripe CLI output.Can't sign in with test account
Can't sign in with test account
Make sure you’ve run the database seed command:If the problem persists, check that your
AUTH_SECRET is set in the .env file.Module not found errors
Module not found errors
Try clearing the Next.js cache and reinstalling dependencies:
Getting Help
If you encounter issues:- Check the GitHub Issues for known problems
- Join the Next.js Discord for community support
- Review the documentation for detailed information
Deploy to Production
Ready to deploy? Learn how to take your app to production