This is a starter template for building a SaaS application using Next.js with support for authentication, Stripe integration for payments, and a dashboard for logged-in users.
Demo: https://next-saas-start.vercel.app/
/
) with animated Terminal element/pricing
) which connects to Stripe Checkout
git clone https://github.com/nextjs/saas-startercd saas-starterpnpm install
Use the included setup script to create your .env
file:
pnpm db:setup
Then, run the database migrations and seed the database with a default user and team:
pnpm db:migratepnpm db:seed
This will create the following user and team:
test@test.com
admin123
You can, of course, create new users as well through /sign-up
.
Finally, run the Next.js development server:
pnpm dev
Open http://localhost:3000 in your browser to see the app in action.
Optionally, you can listen for Stripe webhooks locally through their CLI to handle subscription change events:
stripe listen --forward-to localhost:3000/api/stripe/webhook
To test Stripe payments, use the following test card details:
4242 4242 4242 4242
When you're ready to deploy your SaaS application to production, follow these steps:
https://yourdomain.com/api/stripe/webhook
).checkout.session.completed
, customer.subscription.updated
).In your Vercel project settings (or during deployment), add all the necessary environment variables. Make sure to update the values for the production environment, including:
BASE_URL
: Set this to your production domain.STRIPE_SECRET_KEY
: Use your Stripe secret key for the production environment.STRIPE_WEBHOOK_SECRET
: Use the webhook secret from the production webhook you created in step 1.POSTGRES_URL
: Set this to your production database URL.AUTH_SECRET
: Set this to a random string. openssl rand -base64 32
will generate one.While this template is intentionally minimal and to be used as a learning resource, there are other paid versions in the community which are more full-featured:
This is a starter template for building a SaaS application using Next.js with support for authentication, Stripe integration for payments, and a dashboard for logged-in users.
Demo: https://next-saas-start.vercel.app/
/
) with animated Terminal element/pricing
) which connects to Stripe Checkout
git clone https://github.com/nextjs/saas-startercd saas-starterpnpm install
Use the included setup script to create your .env
file:
pnpm db:setup
Then, run the database migrations and seed the database with a default user and team:
pnpm db:migratepnpm db:seed
This will create the following user and team:
test@test.com
admin123
You can, of course, create new users as well through /sign-up
.
Finally, run the Next.js development server:
pnpm dev
Open http://localhost:3000 in your browser to see the app in action.
Optionally, you can listen for Stripe webhooks locally through their CLI to handle subscription change events:
stripe listen --forward-to localhost:3000/api/stripe/webhook
To test Stripe payments, use the following test card details:
4242 4242 4242 4242
When you're ready to deploy your SaaS application to production, follow these steps:
https://yourdomain.com/api/stripe/webhook
).checkout.session.completed
, customer.subscription.updated
).In your Vercel project settings (or during deployment), add all the necessary environment variables. Make sure to update the values for the production environment, including:
BASE_URL
: Set this to your production domain.STRIPE_SECRET_KEY
: Use your Stripe secret key for the production environment.STRIPE_WEBHOOK_SECRET
: Use the webhook secret from the production webhook you created in step 1.POSTGRES_URL
: Set this to your production database URL.AUTH_SECRET
: Set this to a random string. openssl rand -base64 32
will generate one.While this template is intentionally minimal and to be used as a learning resource, there are other paid versions in the community which are more full-featured: