This is a starter template for building a SaaS application using Next.js with Clerk.js authentication, Polar.sh integration for payments, and a dashboard for logged-in users.
Demo: https://next-saas-start.vercel.app/
- Marketing landing page (
/) with animated Terminal element - Pricing page (
/pricing) with Polar.sh checkout integration - Dashboard pages with CRUD operations on users/teams
- Basic RBAC with Owner and Member roles
- Clerk.js authentication with secure user management
- Global middleware to protect logged-in routes
- Local middleware to protect Server Actions or validate Zod schemas
- Activity logging system for any user events
- Framework: Next.js
- Database: Postgres
- ORM: Drizzle
- Authentication: Clerk.js
- Payments: Polar.sh
- UI Library: shadcn/ui
- Jenkins: Creating a pipeline that handles all stages of testing and deployment
- SonarQube: Testing tool used to report on code quality
- Docker: For effective containerization
- Selenium/Cucumber: Testing tools for BDD of the application
- Jest: Testing for JS applications (unit tests)
And much more maybe added here later.
git clone https://github.com/nextjs/saas-starter
cd saas-starter
pnpm installUse the included setup script to create your .env file:
pnpm db:setupRun the database migrations and seed the database with a default user and team:
pnpm db:migrate
pnpm db:seedThis will create the following test user and team:
- User:
test@test.com - Clerk ID:
user_test123(mock ID for seeding)
You can create new users through Clerk.js authentication via the /sign-up route.
Finally, run the Next.js development server:
pnpm devOpen http://localhost:3000 in your browser to see the app in action.
When you're ready to deploy your SaaS application to production, follow these steps:
- Push your code to a GitHub repository.
- Connect your repository to Vercel and deploy it.
- Follow the Vercel deployment process, which will guide you through setting up your project.
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.POSTGRES_URL: Set this to your production database URL.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: Your Clerk publishable key from https://dashboard.clerk.com/CLERK_SECRET_KEY: Your Clerk secret key from https://dashboard.clerk.com/POLAR_ACCESS_TOKEN: Your Polar.sh access token from https://polar.sh/settings
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: