AI-first Next.js template for rapid development with authentication, database, and Cloudflare Workers deployment.
β Star this repo if you find it useful!
- Who Is This For?
- Conscious Trade-offs & Known Limitations
- Tech Stack
- Features
- Quick Start
- Project Structure
- Available Scripts
- Email Configuration
- Deployment
- Documentation
- Comparison
Perfect for:
- π Startup founders building MVPs rapidly with AI assistance
- πΌ Indie hackers needing auth + RBAC + email flows out-of-the-box
- π€ AI-first developers using Cursor, Claude Code, GitHub Copilot
- π Learners exploring modern Next.js App Router + Drizzle architecture
Not ideal for:
- Teams requiring extensive testing infrastructure from day 1
- Projects with highly custom authentication requirements
- Applications needing complex multi-tenancy from the start
- Real-time applications (WebSocket, live collaboration)
- Heavy computation workloads (video processing, ML inference)
This template prioritizes speed and simplicity for MVP development. Here's what you should know before choosing Templator:
Testing Infrastructure
- No Vitest/Jest, Testing Library, or E2E tests
- Why: 90% of MVPs don't need tests day 1. TypeScript + ESLint catch most bugs.
- When to add: Before first paying customers or when team grows beyond 3 developers
- See docs/LIMITATIONS.md for migration guide
Error Monitoring & Analytics
- No Sentry, Axiom, or analytics integration
- Why: Adds complexity and cost for early prototypes
- When to add: Week 1 of production traffic
- See docs/LIMITATIONS.md for setup guide
Advanced Features
- β WebSocket/real-time (Cloudflare Workers limitation)
- β File uploads (needs R2 bucket configuration)
- β Payment processing (Stripe integration needed)
- β Multi-tenancy (single-organization RBAC only)
- β Internationalization (English-only by default)
- Why: Keep template focused, add these when business validated
Free Tier Limits (100,000 requests/day):
- 10ms CPU time per request
- 128MB memory
- 1MB response size
- Good for: Content sites, forms, auth flows
Paid Tier ($5/mo for 10M requests):
- 30s CPU time (Workers Standard) or 15min (Workers Unbound)
- Still 128MB memory
- 25MB+ response size
- Good for: API-heavy apps, complex queries
What Doesn't Work: WebSocket, filesystem access, long-running background jobs
See docs/LIMITATIONS.md for workarounds and alternatives.
β Enterprise with strict compliance (SOC2, HIPAA day 1) β Use custom build or commercial starter β Complex B2B SaaS (multi-tenancy, teams, 10+ permission levels) β Fork and extend RBAC β Real-time apps (chat, multiplayer, live collaboration) β Consider Supabase integration or traditional server β Heavy computation (video encoding, ML inference) β Use serverless functions or dedicated servers
β Perfect for: Content sites, SaaS MVPs, internal tools, API-first apps, landing pages with auth
For detailed limitations and migration paths, see docs/LIMITATIONS.md. For adding real-time features, see docs/SUPABASE_INTEGRATION.md.
- Next.js 15 - App Router, Server Components, Server Actions
- React 19 - Latest React with Suspense and Transitions
- TypeScript - Strict mode with full type safety
- Tailwind CSS 4 - Utility-first styling
- shadcn/ui - Beautiful, accessible components
- Drizzle ORM - TypeScript-first ORM with edge support
- Neon PostgreSQL - Serverless Postgres with branching
- Better Auth - Modern authentication with built-in security
- Cloudflare Workers - Edge deployment with zero cold starts
- OpenNext - Next.js adapter for Cloudflare
- Turbopack - Ultra-fast bundler for development (built into Next.js 15)
- ESLint - Code linting
- Prettier - Code formatting
- React Hook Form + Zod - Type-safe form validation
|
|
|
|
|
|
|
|
β Pages
- Landing page with Hero, Features, CTA
- Pricing page
- Contact page
- Blog listing and individual post pages
- Authentication pages (login/register)
- Dashboard with role-based sections
- Dashboard overview (all users)
- Profile management (all users)
- Blog management (editor/admin)
- List all posts (draft + published)
- Create new post
- Edit existing post
- Delete post
- Newsletter subscribers (editor/admin)
- Contact messages (editor/admin)
- User management (admin only)
# Using this template on GitHub (recommended)
# Click "Use this template" button at the top of this repo
# Or clone directly
git clone https://github.com/yourusername/templator.git
cd templator
pnpm installCreate .env file:
# Database (Neon PostgreSQL)
DATABASE_URL="postgresql://..."
# Better Auth
BETTER_AUTH_URL="http://localhost:3000"
BETTER_AUTH_SECRET="run: openssl rand -base64 32"
NEXT_PUBLIC_APP_URL="http://localhost:3000"
# Email (optional - mock by default)
ADMIN_EMAIL="admin@yourdomain.com"
# RESEND_API_KEY="re_xxxxx" # Uncomment to enable real emailsGenerate Better Auth secret:
openssl rand -base64 32# Generate migration
pnpm db:generate
# Push to database
pnpm db:push
# Open Drizzle Studio (optional)
pnpm db:studiopnpm devsrc/
βββ app/
β βββ (routes)/ # Page routes
β βββ dashboard/ # Protected dashboard with RBAC
β βββ api/auth/ # Better Auth handler
β βββ layout.tsx # Root layout with providers
β βββ providers.tsx # Client providers (Theme)
βββ components/
β βββ ui/ # shadcn/ui components
β βββ layout/ # Navbar, Footer, ThemeToggle
β βββ auth/ # RBAC components (RoleGate, RoleGateClient)
β βββ dashboard/ # Dashboard components (DashboardNav)
β βββ common/ # Shared components (PageHeader, Section)
βββ features/
β βββ auth/ # Authentication (schema, actions)
β βββ users/ # User management (admin actions)
β βββ profile/ # Profile editing (actions, form)
β βββ blog/ # Blog posts (schema, actions, PostForm)
β βββ contact/ # Contact form feature
β βββ newsletter/ # Newsletter feature
βββ lib/
β βββ auth.ts # Better Auth config
β βββ auth-client.ts # Client-side hooks
β βββ permissions.ts # RBAC permission system
β βββ password.ts # PBKDF2 hashing (Cloudflare Workers compatible)
β βββ utils.ts # Utility functions (cn, etc.)
βββ db/
β βββ schema.ts # Drizzle schema (users with roles)
β βββ index.ts # Database client
βββ hooks/ # Custom React hooks
βββ types/ # TypeScript types (NextAuth extensions)
# Development
pnpm dev # Start dev server with Turbopack
pnpm build # Production build
pnpm start # Start production server
# Code Quality
pnpm lint # Run ESLint
pnpm format # Format code with Prettier
pnpm format:check # Check code formatting
pnpm typecheck # TypeScript type checking
# Database
pnpm db:generate # Generate migrations
pnpm db:push # Push schema to database
pnpm db:studio # Open Drizzle Studio
# Cloudflare
pnpm deploy # Deploy to Cloudflare
pnpm preview # Preview Cloudflare build
pnpm cf-typegen # Generate Cloudflare typesBy default, emails are mocked (logged to console). To enable real emails with Resend:
Note: Resend is already installed in this template.
- Get API key from Resend
- Add to
.env:RESEND_API_KEY="re_xxxxx" EMAIL_FROM="noreply@yourdomain.com" EMAIL_PROVIDER="resend"
- Verify your domain in Resend dashboard (required for production)
See docs/EMAIL_SYSTEM.md for detailed configuration and templates guide.
Why Cloudflare Workers?
- Global edge network with zero cold starts
- Free tier: 100k requests/day
- Perfect match with Neon PostgreSQL
- OpenNext adapter maintains Next.js compatibility
First-time setup:
# Login to Cloudflare
pnpm wrangler login
# Set secrets (don't use plain env vars for sensitive data)
pnpm wrangler secret put DATABASE_URL
pnpm wrangler secret put NEXTAUTH_SECRETDeploy:
# Build and deploy to production
pnpm deploy
# Or preview before deploying
pnpm previewConfiguration:
- Edit
wrangler.jsoncfor worker settings - OpenNext config in
open-next.config.ts
Local development (.env):
DATABASE_URL="postgresql://..."
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="..."
ADMIN_EMAIL="admin@yourdomain.com"Production (Cloudflare):
Set secrets via Wrangler CLI (recommended):
pnpm wrangler secret put DATABASE_URL
pnpm wrangler secret put NEXTAUTH_SECRET
pnpm wrangler secret put ADMIN_EMAILOr set in Cloudflare dashboard β Workers β Settings β Variables and Secrets
Required:
DATABASE_URL- Neon connection stringBETTER_AUTH_URL- Your production URL (e.g., https://yourapp.workers.dev)BETTER_AUTH_SECRET- Same as local (useopenssl rand -base64 32)NEXT_PUBLIC_APP_URL- Same as BETTER_AUTH_URL
Optional:
ADMIN_EMAIL- For contact form notificationsRESEND_API_KEY- If using real email (instead of mock)
-
Add new feature:
mkdir -p src/features/my-feature # Create: schema.ts, actions.ts, MyFeatureForm.tsx, README.md -
Add database table:
- Edit
src/db/schema.ts - Run
pnpm db:generate - Run
pnpm db:push
- Edit
-
Add new page:
- Create in
src/app/my-page/page.tsx - Add link to
Navbar.tsx
- Create in
-
Validation loop (before commit):
pnpm format # Format code pnpm lint # Check linting pnpm typecheck # Check types pnpm build # Test build
See docs/ folder for detailed guides:
LIMITATIONS.md- Known limitations, platform constraints, and migration pathsSUPABASE_INTEGRATION.md- Adding real-time, storage, and enhanced database features with SupabaseAUTHENTICATION.md- Complete Better Auth guide (email/password, verification, password reset)AUTHENTICATION_ADVANCED.md- Advanced auth flows (security, edge compatibility)RBAC.md- Role-Based Access Control system (user/editor/admin)ARCHITECTURE.md- Project structure and conventionsAI_WORKFLOW.md- Working with AI assistants (includes/changelogand/releasecommands)STACK.md- Technology choices and rationale (Drizzle, Better Auth, Cloudflare)DEPLOYMENT.md- Cloudflare Workers deployment guideMIDDLEWARE.md- Authentication middleware (edge-compatible)EMAIL_SYSTEM.md- Email configuration and templatesrecipes/- Step-by-step guides for common tasks
How does Templator compare to other Next.js starters?
| Feature | Templator | create-t3-app | Next.js SaaS Starter |
|---|---|---|---|
| Auth System | β Better Auth + RBAC | β NextAuth | |
| Email Verification | β Built-in | β Manual setup | β Manual setup |
| Password Reset | β Built-in | β Manual setup | β Manual setup |
| Role-Based Access | β 3-tier RBAC | β DIY | β DIY |
| Email Templates | β React Email | β | β |
| Edge Deployment | β Cloudflare Workers | ||
| AI-Optimized | β Feature-based architecture | β | β |
| Documentation | β Comprehensive docs/ | ||
| Database ORM | Drizzle | Drizzle/Prisma | Prisma |
| Blog System | β Built-in | β | β |
Why Drizzle over Prisma?
- TypeScript-first with native type inference
- Better performance for serverless/edge
- Smaller bundle size
- Perfect Cloudflare Workers compatibility
Why Better Auth?
- Modern, actively maintained (Auth.js/NextAuth is now maintained by Better Auth team)
- Built-in rate limiting, email verification, password reset
- TypeScript-first with excellent type inference
- Cloudflare Workers compatible (custom PBKDF2 hashing)
- No SessionProvider wrapper needed
Why Cloudflare Workers?
- Global edge deployment
- Zero cold starts
- Generous free tier (100k req/day)
- Perfect with Neon PostgreSQL
Built with: