A production-ready Next.js 16 SaaS boilerplate with authentication, multi-tenancy, team management, and beautiful UI components built with shadcn/ui.
- β Next.js 16 with App Router and React 19
- β TypeScript for type safety
- β Turbopack for blazing fast builds
- β React Compiler for automatic memoization
- β Tailwind CSS v4 with shadcn/ui components
- β Vercel Analytics for performance monitoring
- β NextAuth.js v4 with email magic links
- β Prisma ORM with SQLite (dev) / PostgreSQL (prod)
- β Session Management with JWT strategy
- β Security Headers via proxy.ts
- β Rate Limiting for API protection
- β Environment Validation with Zod
- β Organization Management with slug-based routing
- β Role-Based Access Control (OWNER, ADMIN, MEMBER, VIEWER)
- β Team Invitations via email
- β Multi-Tenant Database with proper isolation
- β Facebook Login for Business - OAuth integration for commerce
- β Facebook Commerce Platform - Webhook support for orders and catalogs
- β Encrypted Token Storage - Secure credential management
- β 30+ shadcn/ui Components pre-configured
- β Dark Mode with next-themes
- β Toast Notifications with Sonner
- β Responsive Design mobile-first approach
| Category | Technology |
|---|---|
| Framework | Next.js 16.0.3 |
| UI Library | React 19.2 |
| Language | TypeScript 5 |
| Styling | Tailwind CSS v4 |
| Components | shadcn/ui |
| Authentication | NextAuth.js 4.24 |
| Database | Prisma 6.19 |
| Resend |
- Clone and install:
npm install- Set up environment variables in
.env.local:
DATABASE_URL=\"file:./dev.db\"
NEXTAUTH_URL=\"http://localhost:3000\"
NEXTAUTH_SECRET=\"your-secret-min-32-chars\"
RESEND_API_KEY=\"re_your_key\"
EMAIL_FROM=\"noreply@yourdomain.com\"- Generate Prisma Client and run migrations:
npm run prisma:generate
export $(cat .env.local | xargs) && npm run prisma:migrate:dev- Start development:
npm run dev- Facebook App: Create a Facebook App at developers.facebook.com
- App Review: Submit for App Review to access production features
- Permissions Required:
public_profile(default)email(default)pages_read_engagement(for page access)pages_manage_metadata(for page management)catalog_management(for product catalogs)business_management(for business assets)
Add these to your .env.local:
# Facebook Integration
FACEBOOK_APP_ID="your-app-id"
FACEBOOK_APP_SECRET="your-app-secret"
FACEBOOK_WEBHOOK_VERIFY_TOKEN="random-string-for-verification"
ENCRYPTION_KEY="generate-with-openssl-rand-hex-32"Generate Encryption Key:
openssl rand -hex 32- Start OAuth: Redirect users to
/api/auth/facebook/start?tenant=STORE_ID - User Authorization: Facebook prompts user to grant permissions
- Callback: System exchanges code for long-lived token (60 days)
- Asset Discovery: Automatically discovers connected pages, catalogs, and business
- Storage: Encrypts and stores token with tenant isolation
-
Configure in Facebook App Dashboard:
- Webhook URL:
https://your-domain.com/api/facebook/webhook - Verify Token: Use value from
FACEBOOK_WEBHOOK_VERIFY_TOKEN
- Webhook URL:
-
Subscribe to Events:
commerce_orders- Order status updatespage- Page and catalog updatesfeed- Product feed changes
-
Verify Signature: All webhooks verify
X-Hub-Signature-256header
- Each Facebook connection is scoped to a specific Store (tenant)
- State parameter includes signed tenant ID for CSRF protection
- Tokens encrypted at rest using AES-256-GCM
- Query filters always include
storeIdto prevent data leakage
# Start OAuth flow (replace with actual store ID)
curl "http://localhost:3000/api/auth/facebook/start?tenant=YOUR_STORE_ID"
# Test webhook verification
curl "http://localhost:3000/api/facebook/webhook?hub.mode=subscribe&hub.verify_token=YOUR_TOKEN&hub.challenge=test123"π Automatic Database Migration - The deployment process now handles PostgreSQL migrations automatically!
-
Prepare Database: Set up a PostgreSQL database (Vercel Postgres recommended)
-
Configure Environment Variables in Vercel:
DATABASE_URL- PostgreSQL connection stringNEXTAUTH_SECRET- Generate withopenssl rand -base64 32NEXTAUTH_URL- Your production URL (e.g.,https://your-app.vercel.app)EMAIL_FROM- Sender email addressRESEND_API_KEY- Email service API key
-
Deploy:
# Via GitHub (recommended) # Push to GitHub and import in Vercel dashboard # Or via CLI vercel --prod
-
That's it! Database migrations run automatically during build. No manual migration steps required.
What happens during deployment:
- β Install dependencies
- β
Run PostgreSQL migrations automatically (
scripts/migrate-postgres.js) - β Generate Prisma Client for PostgreSQL
- β Create all database tables and indexes
- β Build Next.js application
Option 1: Automatic Seeding During Deployment
To enable automatic seeding of demo data during Vercel deployment:
- Set
SEED_DATABASE=truein Vercel environment variables (Project Settings β Environment Variables) - Deploy or redeploy
- Important: Remove or set
SEED_DATABASE=falseafter seeding to prevent accidental future seeding
See Production Seeding Guide for detailed instructions.
Option 2: Manual Seeding
To populate your production database with demo data manually:
vercel env pull .env.local
export $(cat .env.local | xargs)
npm run prisma:seed:productionDemo Login: test@example.com / Test123!@#
See VERCEL_DEPLOYMENT.md for detailed instructions and troubleshooting.
- Deployment Guide - Deploy to Vercel with PostgreSQL
- Production Seeding - Seed production database with demo data
- PostgreSQL Migration Guide - Migrate from SQLite to PostgreSQL
- Development Guide - Implementation guidance
- Copilot Instructions - Detailed project structure
For Next.js 16 specifics, see official documentation at https://nextjs.org/docs
Built with Next.js 16 and shadcn/ui
npm run prisma:generate # Generate Prisma Client npm run prisma:migrate # Run migrations (dev) npm run prisma:reset # Reset database npm run prisma:push # Push schema changes npm run prisma:seed # Seed database npm run prisma:studio # Open Prisma Studio npm run db:seed # Alias for prisma:seed
π Super Admin Credentials: Email: superadmin@example.com Password: SuperAdmin123!@#
π Test User Credentials (Password: Test123!@#):
Owner: owner@example.com (Password: Test123!@#)
Admin: admin@example.com
Member: member@example.com
Primary Store ID: cmiz4k6ad000dfmrcpwawd3by
Secondary Store ID: cmiz4k6ae000ffmrco99lczvs
"buildCommand": "node scripts/migrate-postgres.js && node scripts/conditional-seed.js && npm run build", "outputDirectory": ".next", "$schema": "https://openapi.vercel.sh/vercel.json", "framework": "nextjs", "installCommand": "npm install" "buildCommand": "npm run vercel-build",