Complete guide to building and deploying AI-powered SAAS applications with our comprehensive starter kit
This comprehensive starter kit provides everything you need to build a modern SAAS application, including authentication, payment processing, AI integration, user management, and a beautiful responsive interface.
NextAuth.js with Google OAuth, protected routes, session management, and role-based access control.
Stripe integration with Pro plan subscriptions, billing dashboard, and webhook handling.
OpenRouter API with multiple AI models, interactive chat interface, and credit-based usage system.
User analytics, revenue tracking, credit monitoring, and comprehensive admin panel.
Tailwind CSS v4, ShadCN UI components, dark/light themes, and responsive design.
Neon PostgreSQL with custom functions, user management, and subscription tracking.
git clone https://github.com/zainulabedeen123/Best-Saas-Kit--V2.git
cd Best-Saas-Kit--V2
npm install
# or
yarn install
# or
pnpm install
cp .env.example .env.local
Fill in your environment variables in .env.local
(see detailed setup below)
.env.local
as DATABASE_URL
The database tables will be created automatically when you first run the app.
http://localhost:3000/api/auth/callback/google
(development)https://yourdomain.com/api/auth/callback/google
(production)GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_...
STRIPE_SECRET_KEY=sk_test_...
https://yourdomain.com/api/stripe/webhook
checkout.session.completed
, payment_intent.succeeded
.env.local
OPENROUTER_API_KEY=sk-or-v1-...
OPENROUTER_MODEL=qwen/qwen3-235b-a22b-2507
RESEND_API_KEY=re_your-resend-api-key
FROM_EMAIL=onboarding@yourdomain.com
SUPPORT_EMAIL=support@yourdomain.com
best-saas-kit-v2/ ├── src/ │ ├── app/ # Next.js App Router │ │ ├── admin/ # Admin panel pages │ │ ├── api/ # API routes │ │ ├── auth/ # Authentication pages │ │ ├── dashboard/ # User dashboard │ │ ├── demo/ # Demo page │ │ └── page.tsx # Landing page │ ├── components/ # React components │ │ ├── admin/ # Admin components │ │ ├── auth/ # Auth components │ │ ├── billing/ # Billing components │ │ ├── chat/ # AI chat components │ │ ├── dashboard/ # Dashboard components │ │ ├── landing/ # Landing page components │ │ └── ui/ # UI components (ShadCN) │ ├── lib/ # Utility functions │ │ ├── auth.ts # NextAuth configuration │ │ ├── database.ts # Database functions │ │ ├── stripe.ts # Stripe utilities │ │ └── ... │ ├── hooks/ # Custom React hooks │ ├── types/ # TypeScript type definitions │ └── middleware.ts # Next.js middleware ├── public/ # Static assets ├── .env.example # Environment variables template ├── .env.local # Your environment variables (not in git) ├── package.json # Dependencies and scripts ├── tailwind.config.js # Tailwind CSS configuration └── tsconfig.json # TypeScript configuration
src/app/
- Next.js 15 App Router pages and layoutssrc/components/
- Reusable React componentssrc/lib/
- Utility functions and configurationssrc/hooks/
- Custom React hooksmiddleware.ts
- Route protection and authenticationlib/auth.ts
- NextAuth.js configurationlib/database.ts
- Database connection and querieslib/stripe.ts
- Payment processing utilitiesThe landing page includes:
Admin users (configured via email) get access to:
src/app/globals.css
for global stylestailwind.config.js
for Tailwind customizationsrc/components/ui/
for UI changessrc/lib/stripe.ts
for pricing changessrc/lib/database.ts
for database schema changessrc/middleware.ts
for route protection.env.local
(OPENROUTER_MODEL
)src/components/chat/
src/lib/database.ts
.env.local
NEXTAUTH_URL
and NEXT_PUBLIC_SITE_URL
to your domainThe application can be deployed to any platform that supports Next.js:
npm run build
and deploy the .next
folderVariable | Description | Required | Example |
---|---|---|---|
NEXTAUTH_URL | Your site URL | http://localhost:3000 | |
NEXTAUTH_SECRET | NextAuth secret key | your-secret-key | |
GOOGLE_CLIENT_ID | Google OAuth client ID | 123456789.apps.googleusercontent.com | |
GOOGLE_CLIENT_SECRET | Google OAuth client secret | GOCSPX-... | |
DATABASE_URL | Neon PostgreSQL connection string | postgresql://user:pass@host/db | |
STRIPE_SECRET_KEY | Stripe secret key | sk_test_... | |
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY | Stripe publishable key | pk_test_... | |
STRIPE_WEBHOOK_SECRET | Stripe webhook secret | whsec_... | |
OPENROUTER_API_KEY | OpenRouter API key | sk-or-v1-... | |
OPENROUTER_MODEL | AI model to use | qwen/qwen3-235b-a22b-2507 | |
RESEND_API_KEY | Resend email API key | re_your-resend-api-key | |
FROM_EMAIL | Email address for sending emails | Optional | onboarding@yourdomain.com |
SUPPORT_EMAIL | Support email address | Optional | support@yourdomain.com |
Error: connect ECONNREFUSED
DATABASE_URL
in .env.local
OAuthCallback error
GOOGLE_CLIENT_ID
and GOOGLE_CLIENT_SECRET
NEXTAUTH_URL
matches your domainWebhook signature verification failed
STRIPE_WEBHOOK_SECRET
in .env.local
OpenRouter API error
OPENROUTER_API_KEY
is validOPENROUTER_MODEL
is available