A complete full-stack starter kit that integrates Next.js with Stripe payments, NextAuth authentication, and ShadcnUI components. This project provides a solid foundation for building SaaS applications with subscription-based business models.
- NextAuth.js integration with Prisma adapter
 - Google OAuth authentication
 - Role-based access control (USER, PREMIUM, ADMIN)
 - Session management and middleware protection
 - User profile management
 
- Prisma ORM for type-safe database operations
 - PostgreSQL database with enum support
 - Automated schema migrations
 - Database seeding support
 - Simplified schema - Stripe products as single source of truth
 
- Stripe integration for payment processing
 - Subscription management with webhooks
 - Dynamic pricing from Stripe products
 - Customer portal integration
 - Automatic subscription status updates
 - Payment history tracking
 
- Token-based usage tracking from Stripe product metadata
 - Automatic token allocation on subscription
 - 30-day token expiration with auto-renewal for active subscriptions
 - Token consumption tracking
 - Admin token management
 
- Comprehensive admin dashboard at 
/admin - User management and role assignment
 - Subscription and payment overview
 - Product and token management
 - System statistics and analytics
 
- ShadcnUI component library
 - Tailwind CSS for styling
 - Responsive design
 - Dark mode support (Tailwind-based)
 - Toast notifications with Sonner
 
- Free tier content (authenticated users)
 - Premium content (subscription required)
 - Token-based feature access
 - Role-based access control
 - Subscription status validation
 
βββ app/
β   βββ api/
β   β   βββ auth/[...nextauth]/     # NextAuth API routes
β   β   βββ stripe/
β   β       βββ checkout/           # Stripe checkout session
β   β       βββ webhooks/           # Stripe webhooks
β   βββ admin/                      # Admin panel (ADMIN role only)
β   βββ auth/
β   β   βββ signin/                 # Sign-in page
β   βββ dashboard/                  # User dashboard with tokens
β   βββ free-content/               # Free tier content
β   βββ premium-content/            # Premium subscriber content
β   βββ pricing/                    # Pricing and plans page
β   βββ error/                      # Error handling page
βββ components/
β   βββ admin/                      # Admin dashboard components
β   βββ auth/                       # Authentication components
β   βββ dashboard/                  # Dashboard components
β   βββ pricing/                    # Pricing components
β   βββ providers/                  # Context providers
β   βββ ui/                         # ShadcnUI components
βββ lib/
β   βββ auth.ts                     # NextAuth configuration
β   βββ stripe.ts                   # Stripe configuration
β   βββ stripe-admin.ts             # Stripe admin functions
β   βββ subscription.ts             # Subscription & token utilities
βββ prisma/
β   βββ schema.prisma               # Database schema with enums
β   βββ seed.ts                     # Stripe product sync
β   βββ seed-admin.ts               # Admin user setup
βββ types/
    βββ next-auth.d.ts              # NextAuth type extensions
Create a .env.local file in the root directory with the following variables:
# Database
DATABASE_URL="postgresql://postgres:password@localhost:5432/forger_starter_kit"
# NextAuth (Generate a random secret with: openssl rand -base64 32)
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-nextauth-secret-32-characters-minimum"
# Google OAuth
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
# Stripe
STRIPE_SECRET_KEY="sk_test_your-secret-key"
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY="pk_test_your-publishable-key"
STRIPE_WEBHOOK_SECRET="whsec_your-webhook-secret"
# Admin Setup
ADMIN_EMAIL="[email protected]"
# App
NEXT_PUBLIC_APP_URL="http://localhost:3000"- Install PostgreSQL locally or use a cloud provider
 - Create a new database for the project
 - Update the 
DATABASE_URLin your environment variables 
# Generate Prisma client
yarn prisma generate
# Push schema to database
yarn prisma db push
# Sync products from Stripe to database
yarn db:sync-stripe
# Set up admin user (requires ADMIN_EMAIL env var)
yarn db:setup-admin- Go to Google Cloud Console
 - Create a new project or select existing
 - Enable Google+ API
 - Create OAuth 2.0 credentials
 - Add authorized redirect URIs:
http://localhost:3000/api/auth/callback/googlehttps://yourdomain.com/api/auth/callback/google
 
- Create account at Stripe
 - Get API keys from Developers > API keys
 - Create products and prices in the dashboard
 - Set up webhooks pointing to 
/api/stripe/webhooks 
To enable token allocation, add metadata to your Stripe products:
{
  "tokens": "100"
}This will allocate 100 tokens to users when they subscribe to this product.
Configure these webhook events in Stripe:
product.createdproduct.updatedproduct.deletedprice.createdprice.updatedprice.deletedcheckout.session.completedcustomer.subscription.createdcustomer.subscription.updatedcustomer.subscription.deletedpayment_intent.succeeded
After setting up the database and environment variables:
- First, the user must sign in to create their database record
 - Then run the admin setup command:
 
# Set up admin user (user must exist in database first)
yarn db:setup-adminThis will update an existing user with the email specified in ADMIN_EMAIL and assign them the ADMIN role. The user must have signed in at least once for their record to exist in the database.
# Install dependencies
yarn install
# Start development server
yarn dev
# Open http://localhost:3000- Automatic Allocation: Tokens are automatically allocated based on Stripe product metadata
 - Expiration: Tokens expire every 30 days
 - Auto-Renewal: Active subscribers get their tokens renewed automatically
 - Usage Tracking: Track token consumption across your application
 
Access the admin panel at /admin (requires ADMIN role):
- User Management: View all users, their roles, and token balances
 - Subscription Overview: Monitor active subscriptions and revenue
 - Payment History: Track all payments and their status
 - Product Management: View Stripe products and their token allocations
 
- USER: Basic authenticated users
 - PREMIUM: Users with active subscriptions
 - ADMIN: Full system access including admin panel
 
The system now uses Stripe products as the single source of truth:
- No redundant membership tier tables
 - Direct integration with Stripe data
 - Simplified database schema
 - Better performance with fewer joins
 
- Landing Page: Introduction and feature overview
 - Authentication: Sign in with Google
 - Dashboard: Overview of available content
 - Free Content: Accessible to all authenticated users
 - Premium Content: Requires active subscription
 - Pricing: Subscribe to premium plans
 - Subscription Management: View and manage subscriptions
 
- Public: Landing page, pricing, authentication
 - Authenticated: Dashboard, free content
 - Subscribed: Premium content, advanced features
 
- Server-side session validation
 - Protected API routes
 - Stripe webhook signature verification
 - Environment variable validation
 - SQL injection prevention (Prisma)
 
- Connect your GitHub repository
 - Add environment variables in Vercel dashboard
 - Deploy with automatic builds
 
- Netlify: Configure build settings
 - Railway: Direct deployment from GitHub
 - DigitalOcean: App Platform deployment
 
# Run type checking
yarn type-check
# Run linting
yarn lint
# Build for production
yarn build- Next.js Documentation
 - NextAuth.js Documentation
 - Stripe Documentation
 - Prisma Documentation
 - ShadcnUI Documentation
 
- Fork the repository
 - Create a feature branch
 - Make your changes
 - Add tests if applicable
 - Submit a pull request
 
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the GitHub repository
 - Check the documentation links above
 - Review the environment variable requirements
 
Note: This is a starter template designed for developers. All credentials and API keys need to be configured before the application will work properly.
If you encounter a JWT session error, it's usually due to:
- 
Missing or invalid NEXTAUTH_SECRET: Generate a proper secret:
# Generate a secure secret openssl rand -base64 32 - 
Cached sessions: Clear Next.js cache and browser cookies:
rm -rf .next # or on Windows Remove-Item -Recurse -Force .next - 
Environment variables: Ensure all required env vars are set correctly.
 
To test webhooks locally:
Installation: https://docs.stripe.com/stripe-cli?install-method=linux
For wsl:
curl -s https://packages.stripe.dev/api/security/keypair/stripe-cli-gpg/public | gpg --dearmor | sudo tee /usr/share/keyrings/stripe.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/stripe.gpg] https://packages.stripe.dev/stripe-cli-debian-local stable main" | sudo tee -a /etc/apt/sources.list.d/stripe.list
sudo apt update
sudo apt install stripe
stripe listen --forward-to localhost:3000/api/stripe/webhooks