saas-starter README

The project's README from github.com/nextjs/saas-starter. As one markdown file: README.md.

Next.js SaaS Starter

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/

Features

Tech Stack

Getting Started

git clone https://github.com/nextjs/saas-starter
cd saas-starter
pnpm install

Running Locally

Install and log in to your Stripe account:

stripe login

Use the included setup script to create your .env file:

pnpm db:setup

Run the database migrations and seed the database with a default user and team:

pnpm db:migrate
pnpm db:seed

This will create the following user and team:

You can also create new users through the /sign-up route.

Finally, run the Next.js development server:

pnpm dev

Open http://localhost:3000 in your browser to see the app in action.

You can listen for Stripe webhooks locally through their CLI to handle subscription change events:

stripe listen --forward-to localhost:3000/api/stripe/webhook

Testing Payments

To test Stripe payments, use the following test card details:

Going to Production

When you're ready to deploy your SaaS application to production, follow these steps:

Set up a production Stripe webhook

  1. Go to the Stripe Dashboard and create a new webhook for your production environment.
  2. Set the endpoint URL to your production API route (e.g., https://yourdomain.com/api/stripe/webhook).
  3. Select the events you want to listen for (e.g., checkout.session.completed, customer.subscription.updated).

Deploy to Vercel

  1. Push your code to a GitHub repository.
  2. Connect your repository to Vercel and deploy it.
  3. Follow the Vercel deployment process, which will guide you through setting up your project.

Add environment variables

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:

  1. BASE_URL: Set this to your production domain.
  2. STRIPE_SECRET_KEY: Use your Stripe secret key for the production environment.
  3. STRIPE_WEBHOOK_SECRET: Use the webhook secret from the production webhook you created in step 1.
  4. POSTGRES_URL: Set this to your production database URL.
  5. AUTH_SECRET: Set this to a random string. openssl rand -base64 32 will generate one.

Other Templates

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:

saas-starter (nextjs/saas-starter)

Searching Database…

What is this?A free, open-source starter template for building a SaaS web app on Next.js, maintained under the official Next.js org: authentication, Stripe payments, and a dashboard for logged-in users come already wired up.
Is this a finished product or code I'm supposed to build on?It's a code template you clone and build your own product on, not something you install. The README bills it as intentionally minimal and doubles as a learning resource, pointing to paid community versions if you want more features out of the box.
How do I get it running locally?Install and log in to your Stripe account, run the included setup script to create your .env file, then run the database migrations and seed — that creates a default team with user [email protected] (password admin123). Finally, start the Next.js dev server (next dev --turbopack).
What accounts or services do I need before I can run it?A Postgres database and a Stripe account. The stack is Next.js, Postgres, Drizzle ORM, Stripe, and shadcn/ui, plus the Stripe CLI for listening to webhooks locally.
Is it ready to launch as-is, or is there work left for production?It's deliberately minimal — a foundation, not a full product. Going live is your job: create a production Stripe webhook, deploy to Vercel, and set env vars like STRIPESECRETKEY, STRIPEWEBHOOKSECRET, POSTGRESURL and AUTHSECRET yourself.
Do I need to be an experienced Next.js developer to use it?It helps, since you'll be extending a TypeScript/Next.js codebase with Drizzle and Stripe. But it's explicitly positioned as a learning resource, so studying it is a legitimate way to use it.
What's included out of the box?A marketing landing page, a pricing page connected to Stripe Checkout, dashboard pages with CRUD on users and teams, basic Owner/Member RBAC, subscription management via the Stripe Customer Portal, email/password auth with JWTs in cookies, route-protecting middleware, and an activity logging system.
How do I manage database schema changes?The project uses Drizzle with drizzle-kit: db:generate creates migrations, db:migrate applies them, and db:studio opens a GUI for browsing the data.
Can I test payments without a real card?Yes. Use Stripe's test card 4242 4242 4242 4242 with any future expiration date and any 3-digit CVC, and listen for subscription events through the Stripe CLI locally.
Creator
nextjs
Size
0.4 MB
Stars
16.2K
Updated
CommitDec 11
Age
2y
Commits · 90 Days