A production-ready, full-stack SaaS boilerplate built with Next.js 14, featuring user authentication, subscription management, and modern UI components. This starter template provides everything you need to launch a subscription-based SaaS application quickly.
- User Authentication - Secure authentication system powered by NextAuth.js with email/password and OAuth support
- Subscription Management - Integrated LemonSqueezy payment processing for subscription billing
- User Profiles - Complete user profile management with account settings
- Database Integration - Prisma ORM with PostgreSQL for robust data management
- Email System - Transactional emails via Resend for notifications and password resets
- Next.js 14 - App Router with Server Components and Server Actions
- TypeScript - Full type safety across the application
- Modern UI - Beautiful, accessible components built with Radix UI and shadcn/ui
- Responsive Design - Mobile-first, fully responsive layouts
- Route Protection - Middleware-based authentication and authorization
- SEO Optimized - Built-in sitemap generation and metadata management
- Form Validation - Zod schema validation with React Hook Form
- Toast Notifications - User-friendly notification system
- App Directory - Next.js 14 App Router architecture
- Route Groups - Organized route structure with layout groups
- Intercepting Routes - Advanced routing patterns for modals and overlays
- Parallel Routes - Concurrent route rendering capabilities
- CSR/SSR - Optimized client and server-side rendering strategies
Before you begin, ensure you have the following installed:
- Node.js 18.x or higher
- PostgreSQL database (local or cloud-hosted)
- npm or yarn package manager
- Framework: Next.js 14.1.0
- Language: TypeScript 5.2.2
- Styling: Tailwind CSS 3.3.3
- UI Components: Radix UI, shadcn/ui
- Authentication: NextAuth.js 4.22.1
- Database: PostgreSQL with Prisma ORM 4.16.2
- Payments: LemonSqueezy
- Email: Resend 3.2.0
- Icons: Lucide React
- Form Handling: React Hook Form with Zod validation
-
Clone the repository
git clone <your-repo-url> cd <project-directory>
-
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory with the following variables:# Database POSTGRES_PRISMA_URL=your_postgres_connection_string POSTGRES_URL_NON_POOLING=your_direct_postgres_connection_string # NextAuth NEXTAUTH_URL=http://localhost:3000 NEXTAUTH_SECRET=your_nextauth_secret # Generate NextAuth secret using: # openssl rand -base64 32 # LemonSqueezy LEMONSQUEEZY_API_KEY=your_lemonsqueezy_api_key LEMONSQUEEZY_STORE_ID=your_store_id LEMONSQUEEZY_WEBHOOK_SECRET=your_webhook_secret # Email (Resend) RESEND_API_KEY=your_resend_api_key EMAIL_FROM=[email protected] # OAuth (Optional) GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret
-
Set up the database
npx prisma migrate dev --name init
-
Start the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000 to see your application.
The application uses Prisma with the following main models:
- User - User accounts with authentication and subscription data
- Account - OAuth provider accounts
- Session - User session management
βββ app/ # Next.js App Router pages and layouts
β βββ (auth)/ # Authentication route group
β βββ (mainPage)/ # Main page route group
β βββ layout.tsx # Root layout
βββ actions/ # Server actions
β βββ email.ts # Email-related actions
β βββ user.ts # User-related actions
βββ components/ # React components
βββ config/ # Configuration files
β βββ dashboard.ts # Dashboard configuration
β βββ email.ts # Email configuration
β βββ site.ts # Site configuration
βββ lib/ # Utility libraries
β βββ axios.ts # HTTP client configuration
β βββ lemon.ts # LemonSqueezy integration
β βββ prisma.ts # Prisma client
β βββ subscription.ts # Subscription utilities
β βββ utils.ts # General utilities
βββ prisma/ # Prisma schema and migrations
β βββ schema.prisma # Database schema
βββ types/ # TypeScript type definitions
βββ validations/ # Zod validation schemas
npm run dev- Start development server with Prisma generationnpm run build- Build for production with database pushnpm run start- Start production servernpm run lint- Run ESLintnpm run format- Check code formattingnpm run format:write- Format code with Prettiernpm run db:migrate- Run database migrations
The application supports multiple authentication methods:
- Email/Password - Traditional email and password authentication
- OAuth Providers - Google OAuth integration (extensible to other providers)
Authentication is handled by NextAuth.js with session management and protected routes via middleware.
LemonSqueezy integration provides:
- Subscription plan management
- Webhook handling for subscription events
- Customer and subscription tracking
- Period-based billing cycles
Transactional emails are sent via Resend for:
- Welcome emails
- Password reset requests
- Subscription confirmations
- Account notifications
Update config/site.ts to customize:
- Site name and description
- Social media links
- Branding information
The project uses Tailwind CSS with custom configuration. Modify tailwind.config.js to adjust the design system.
UI components are built with shadcn/ui and can be customized in the components/ directory.
- Push your code to GitHub
- Import your repository in Vercel
- Add environment variables in Vercel dashboard
- Deploy
The application can be deployed to any platform that supports Next.js:
- Railway
- Render
- AWS
- DigitalOcean
Ensure your PostgreSQL database is accessible and all environment variables are configured.
This project is open source and available under the MIT License.
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
- This is a starter template - customize it to fit your specific needs
- Always use environment variables for sensitive data
- Regularly update dependencies for security patches
- Test thoroughly before deploying to production
- Configure proper CORS and security headers for production
- Next.js Documentation
- Prisma Documentation
- NextAuth.js Documentation
- LemonSqueezy Documentation
- Tailwind CSS Documentation
- shadcn/ui Documentation
Built with β€οΈ using Next.js and modern web technologies.