A modern, fully-featured Next.js starter template built with the T3 Stack, featuring comprehensive authentication, beautiful UI components, and developer-first experience.
- Overview
- Tech Stack
- Features
- Prerequisites
- Quick Start
- Project Structure
- Database Setup
- Authentication System
- Email System
- API Layer (tRPC)
- UI Components
- Environment Variables
- Development Workflow
- Scripts
- Deployment
- Devbox (Reproducible Dev Environment)
- Contributing
- License
NextCelerator is a production-ready Next.js starter template that combines the power of the T3 Stack with modern authentication using Better Auth. It provides a solid foundation for building web applications with features like user authentication, session management, email verification, account settings, and more.
Author: Endalkachew Biruk (@endalk200)
- Next.js 15 - React framework with App Router
- React 19 - Latest React with concurrent features
- TypeScript 5.8 - Type-safe JavaScript
- tRPC 11 - End-to-end typesafe APIs
- Prisma 6.5 - Type-safe database ORM
- PostgreSQL - Production database
- Zod 3.25 - Runtime type validation
- Better Auth 1.3 - Modern authentication library
- Session Management - Secure cookie-based sessions
- Social Auth - Google & GitHub OAuth integration
- Email Verification - Built-in email verification system
- Tailwind CSS 4 - Utility-first CSS framework
- shadcn/ui - High-quality React components
- Radix UI - Unstyled, accessible UI primitives
- Lucide React - Beautiful icon library
- next-themes - Dark/light theme support
- TypeScript - Full type safety
- ESLint - Code linting
- Prettier - Code formatting
- pnpm 9.12 - Fast package manager
- React Email - JSX email templates
- Resend - Email delivery service
- Email/Password Authentication with secure password requirements
- Social Authentication (Google, GitHub)
- Email Verification with custom templates
- Password Reset functionality
- Session Management with automatic refresh
- Account Linking - Link multiple auth providers
- Account Deletion with email confirmation
- Dark/Light Theme support with system preference detection
- Responsive Design optimized for all devices
- Beautiful Components using shadcn/ui
- Loading States and error handling
- Toast Notifications for user feedback
- Verification Emails for new accounts
- Password Reset Emails
- Email Change Verification
- Account Deletion Confirmation
- Responsive Email Templates using React Email
- CSRF Protection built into Better Auth
- Secure Session Handling with httpOnly cookies
- Email Verification Required
- Rate Limiting on sensitive operations
- Middleware Protection for authenticated routes
- User Dashboard with account overview
- Account Settings page with:
- Profile information management
- Password change functionality
- Email change with verification
- Active session management
- Account linking/unlinking
- Account deletion
- Type Safety throughout the entire stack
- Hot Reload with Turbo mode
- Database Management with Prisma Studio
- API Documentation via tRPC
- Environment Validation with zod
- Node.js v21.6.0 (local toolchain); Devbox pins Node 21 to match
- pnpm v9.12.3 (pinned via packageManager and corepack)
- jq v1.7.1
- PostgreSQL database (local or cloud)
- Git for version control
git clone https://github.com/endalk200/nextcelerator.git
cd nextceleratorpnpm installCopy the environment variables template:
cp .env.example .envConfigure your .env file with the required variables (see Environment Variables section).
# Push schema to your database
pnpm db:push
# Or run migrations (for production)
pnpm db:migratepnpm devVisit http://localhost:3000 to see your application running.
nextcelerator/
├── src/
│ ├── app/ # Next.js App Router
│ │ ├── _components/ # Shared app components
│ │ ├── api/ # API routes
│ │ │ ├── auth/ # Better Auth API endpoint
│ │ │ └── trpc/ # tRPC API endpoint
│ │ ├── dashboard/ # Protected dashboard pages
│ │ │ ├── settings/ # Account settings
│ │ │ └── delete-account/ # Account deletion
│ │ ├── (auth)/ # Authentication pages
│ │ │ ├── signin/
│ │ │ ├── signup/
│ │ │ ├── forgot-password/
│ │ │ ├── reset-password/
│ │ │ └── verify-email/
│ │ ├── layout.tsx # Root layout
│ │ └── page.tsx # Landing page
│ ├── components/ # Reusable UI components
│ │ ├── ui/ # shadcn/ui components
│ │ ├── app-sidebar.tsx # Application sidebar
│ │ └── theme-provider.tsx # Theme context provider
│ ├── emails/ # Email templates
│ │ ├── components/ # Email-specific components
│ │ ├── verify-email.tsx
│ │ ├── reset-password.tsx
│ │ ├── change-email-verification.tsx
│ │ └── delete-account-confirmation.tsx
│ ├── hooks/ # Custom React hooks
│ ├── lib/ # Utility libraries
│ │ ├── auth/ # Authentication setup
│ │ │ ├── auth.ts # Better Auth server config
│ │ │ ├── auth-client.ts # Better Auth client config
│ │ │ └── index.ts
│ │ ├── utils/ # Utility functions
│ │ └── email.ts # Email service functions
│ ├── server/ # Server-side code
│ │ ├── api/ # tRPC API layer
│ │ │ ├── routers/ # API route definitions
│ │ │ │ └── account.ts # Account management endpoints
│ │ │ ├── root.ts # Main API router
│ │ │ └── trpc.ts # tRPC setup
│ │ └── db.ts # Database connection
│ ├── styles/ # Styling
│ │ └── globals.css # Global styles & Tailwind
│ ├── trpc/ # tRPC client setup
│ │ ├── react.tsx # React Query integration
│ │ ├── server.ts # Server-side client
│ │ └── query-client.ts # Query client configuration
│ ├── env.js # Environment variable validation
│ └── middleware.ts # Next.js middleware
├── prisma/ # Database schema & migrations
│ ├── schema.prisma # Database schema
│ └── migrations/ # Database migrations
├── public/ # Static assets
└── [config files] # Various configuration filesThe database uses PostgreSQL with Prisma ORM and includes these main models:
- User - User accounts with profile information
- Session - User sessions with expiration tracking
- Account - Linked authentication providers
- Verification - Email verification tokens
- Post - Example content model (from T3 template)
model User {
id String @id
name String
email String @unique
emailVerified Boolean
image String?
createdAt DateTime
updatedAt DateTime
sessions Session[]
accounts Account[]
}
model Session {
id String @id
expiresAt DateTime
token String @unique
userId String
user User @relation(fields: [userId], references: [id], onDelete: Cascade)
// ... additional fields
}# Push schema changes to database (development)
pnpm db:push
# Generate and run migrations (production)
pnpm db:generate
pnpm db:migrate
# Open Prisma Studio (database GUI)
pnpm db:studio
# Reset database (careful!)
npx prisma migrate resetNextCelerator uses Better Auth for a comprehensive authentication system:
- Database Integration via Prisma adapter
- Email/Password Authentication with verification required
- Social Authentication (Google, GitHub)
- Session Management with 7-day expiration
- Email Verification with custom callbacks
- Account Linking support
- Account Deletion with confirmation workflow
Exports all authentication functions:
signIn,signUp,signOutuseSessionReact hookforgetPassword,resetPasswordchangeEmail,changePassworddeleteUser,updateUserlistSessions,revokeSession- Social account linking/unlinking
- Sign Up: User creates account → Email verification sent → Account activated
- Sign In: Credentials verified → Session created → Redirect to dashboard
- Password Reset: Email sent → Token validated → Password updated → Sessions revoked
- Email Change: Verification sent to current email → New email verified → Email updated
- Account Deletion: Confirmation email → Token validated → Account permanently deleted
Protected routes use Next.js middleware (src/middleware.ts):
// Redirects unauthenticated users to sign-in
if (request.nextUrl.pathname.startsWith("/dashboard")) {
if (!sessionCookie) {
return NextResponse.redirect(new URL("/signin", request.url));
}
}Built with React Email for responsive, accessible templates:
- Email Verification (
verify-email.tsx) - Welcome & account activation - Password Reset (
reset-password.tsx) - Secure password reset - Email Change (
change-email-verification.tsx) - Email change confirmation - Account Deletion (
delete-account-confirmation.tsx) - Account deletion warning
Uses Resend for reliable email delivery:
// Send verification email
await sendVerificationEmail({
user: { email: "user@example.com", name: "John" },
url: "https://app.com/verify?token=...",
token: "verification-token",
});- From Address:
NextCelerator <support@support.endalk200.com> - Provider: Resend API
- Templates: React Email components with inline styles
- Error Handling: Graceful fallbacks with logging
Create a .env file with these variables:
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/nextcelerator"
# Better Auth
BETTER_AUTH_SECRET="your-32-character-secret-key-here"
BETTER_AUTH_URL="http://localhost:3000"
# Social Authentication
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"
# Email Service
RESEND_API_KEY="your-resend-api-key"
# Environment
NODE_ENV="development"Uses @t3-oss/env-nextjs for runtime validation:
- Type Safety - Environment variables are typed
- Validation - Zod schemas ensure correct values
- Build Safety - Build fails with invalid environment
Located in src/server/api/trpc.ts with:
- Context Creation with session and database access
- Authentication Middleware for protected procedures
- Error Formatting with Zod validation errors
- Development Timing middleware with artificial delays
getUserInfo- Get user profile informationgetLinkedAccounts- List connected authentication providersgetAuthProviders- Check available auth methodssetPassword- Set password for social auth users
// Client-side usage
const { data: userInfo } = api.account.getUserInfo.useQuery();
// Server-side usage
const userInfo = await api.account.getUserInfo();Full end-to-end type safety from database to frontend:
// Automatically typed based on tRPC procedures
type UserInfo = RouterOutputs["account"]["getUserInfo"];NextCelerator uses shadcn/ui with the "New York" style:
- Design System: Consistent, accessible components
- Customization: Easy theme customization via CSS variables
- Dark Mode: Built-in dark/light theme support
- Forms - React Hook Form with Zod validation
- Data Display - Cards, badges, tables
- Navigation - Sidebar, breadcrumbs, dropdowns
- Feedback - Toast notifications, loading states, alerts
- Overlays - Modals, tooltips, sheets
// Dark theme by default with system preference detection
<ThemeProvider
attribute="class"
defaultTheme="dark"
enableSystem
storageKey="nextcelerator-theme"
>- TypeScript - Strict mode enabled with
noUncheckedIndexedAccess - ESLint - Next.js recommended rules + TypeScript ESLint
- Prettier - Code formatting with Tailwind CSS plugin
- Husky - Git hooks for pre-commit checks (if configured)
- Schema Changes - Modify
prisma/schema.prisma - Push Changes -
pnpm db:pushfor development - Generate Migrations -
pnpm db:generatefor production - Studio -
pnpm db:studiofor visual database management
// Render email template to HTML for testing
const html = await renderEmailToHtml("verify", {
username: "Test User",
verificationUrl: "https://example.com/verify",
});pnpm dev # Start development server with Turbo
pnpm check # Run linting and type checking
pnpm lint # Run ESLint
pnpm lint:fix # Fix ESLint issues
pnpm typecheck # Run TypeScript compilerpnpm db:push # Push schema to database (dev)
pnpm db:generate # Generate migration files
pnpm db:migrate # Run migrations (production)
pnpm db:studio # Open Prisma Studiopnpm format:check # Check code formatting
pnpm format:write # Format codepnpm build # Build for production
pnpm start # Start production server
pnpm preview # Build and start production serverThis repo includes Devbox configuration for a fully reproducible local environment.
- Tools provided in Devbox shell:
- Node.js 21.x (aligned with local toolchain)
- pnpm 9.12.3 (via corepack, read from package.json's packageManager)
- jq 1.7.x
Follow https://www.jetify.com/devbox/docs/install/ to install Devbox.
# Start a dev shell with pinned tools
devbox shell
# Inside the shell, verify versions
node -v # expected: v21.x
pnpm -v # expected: 9.12.3
jq --version # expected: 1.7.x
# Install deps and generate Prisma client (post_create hook also runs this)
pnpm install --frozen-lockfile
pnpm prisma generate
# Run the usual workflows
pnpm dev
pnpm db:pushdevbox run -- pnpm buildDevbox reads devbox.json and runs devbox.d/init.sh to pin pnpm via corepack using the packageManager field.
devbox.d/ is a conventional directory for project-specific Devbox scripts and hooks. In this repo:
devbox.d/init.shruns when a Devbox shell starts. It:- Enables Corepack
- Activates the pnpm version from
package.json(falls back to 9.12.3) - Exports helpful env vars (e.g.,
NEXT_TELEMETRY_DISABLED) - Prints tool versions for visibility
Should it be version tracked? Yes. Commit devbox.json and devbox.d/ so every contributor gets the same environment behavior. Avoid storing secrets or machine-specific paths inside these files.
- Push to GitHub - Ensure your code is in a GitHub repository
- Connect to Vercel - Import your repository on Vercel
- Environment Variables - Add all required environment variables in Vercel dashboard
- Database - Use a cloud PostgreSQL provider (Neon, Supabase, Railway)
- Deploy - Vercel automatically builds and deploys
The application can be deployed to any platform that supports Next.js:
- Netlify - Full Next.js support
- Railway - Includes database hosting
- DigitalOcean App Platform - Easy container deployment
- Docker - Use the included Dockerfile (if present)
Ensure these environment variables are set in production:
- Set
NODE_ENV=production - Use production database URL
- Configure proper
BETTER_AUTH_URLwith your domain - Use production API keys for email and social auth
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes following the existing code style
- Run tests and linting (
pnpm check) - Commit your changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Use existing UI components when possible
- Write meaningful commit messages
- Add proper error handling
- Test your changes thoroughly
This project is licensed under the MIT License. See the LICENSE file for details.
Built with ❤️ by Endalkachew Biruk
For questions or support, please open an issue on GitHub or reach out on social media.