A modern, production-ready Next.js template featuring type-safe APIs, secure authentication, and a robust database layer.
- Next.js 15 with App Router and Turbopack
- tRPC for end-to-end type-safe APIs
- Drizzle ORM with PostgreSQL (Neon)
- Better Auth for secure authentication
- Tailwind CSS v4 for styling
- TypeScript with strict mode
- React Hook Form with Zod validation
- TanStack Query for data fetching
- Node.js 18+
- PostgreSQL database (we recommend Neon)
- pnpm, npm, or yarn
- Clone this repository:
git clone <your-repo-url>
cd <your-project-name>- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env.local- Update
.env.localwith your values:
DATABASE_URL=your_postgres_connection_string
NEXT_PUBLIC_APP_URL=http://localhost:3000- Push database schema:
npm run db:push- Run the development server:
npm run devOpen http://localhost:3000 to see your app.
src/
├── app/ # Next.js App Router pages
│ ├── (auth)/ # Authentication pages
│ └── api/ # API routes
├── components/ # React components
│ └── ui/ # UI components (buttons, forms, etc.)
├── db/ # Database configuration
│ └── schema.ts # Drizzle schema definitions
├── lib/ # Utility functions and configs
├── server/ # Server-side code
│ └── api/ # tRPC API implementation
└── trpc/ # tRPC client setup
npm run dev- Start development server with Turbopacknpm run build- Build for productionnpm run start- Start production servernpm run lint- Run ESLintnpm run format- Format code with Prettiernpm run type-check- Run TypeScript type checkingnpm run db:generate- Generate database migrationsnpm run db:migrate- Run database migrationsnpm run db:push- Push schema to database
This template uses Better Auth for authentication with the following features:
- Email/password authentication
- Session management
- Protected API routes
- Client-side session hooks
The template uses Drizzle ORM with PostgreSQL. The schema includes:
- User management tables
- Session storage
- Account linking
- Email verification
To modify the schema, edit src/db/schema.ts and run:
npm run db:generate
npm run db:pushTailwind CSS v4 is pre-configured with:
- Custom color scheme
- Responsive design utilities
- Component classes
- Dark mode support (ready to implement)
- Create a new file in
src/server/api/routers/ - Define your router procedures
- Add the router to
src/server/api/root.ts
- Create a new directory in
src/app/ - Add a
page.tsxfile - The route will be automatically available
- Update
src/db/schema.ts - Generate migrations:
npm run db:generate - Apply changes:
npm run db:push
This template is ready for deployment to:
- Vercel (recommended)
- Netlify
- Railway
- Any Node.js hosting platform
Remember to:
- Set production environment variables
- Run database migrations
- Build the application
MIT
Contributions are welcome! Please feel free to submit a Pull Request.