A full-stack starter template built with modern technologies:
- β Next.js App Router
- π Better Auth
- π§± Drizzle ORM + PostgreSQL
- π§ TRPC + TanStack Query (React Query)
- π Secure sessions & role-based access
- π οΈ Built with Bun, TypeScript, and Zod
| Technology | Purpose |
|---|---|
| Next.js | App Router + Server Actions |
| Better Auth | Authentication & Authorization |
| Drizzle ORM | Type-safe SQL with PostgreSQL |
| TanStack Query | Client-side fetching + caching |
| TRPC | Type-safe backend API calls |
| Zod | Schema validation |
| Bun | Runtime + Tooling |
git clone https://github.com/Chust3r/next-better-stack.git
cd next-better-stack
bun install
# or: pnpm install / npm install / yarn installCreate a .env file in the root directory and set the following environment variables:
# .env
# Better Auth
BETTER_AUTH_SECRET=cz6qRoGz7DXXomsUpeSlIEPs5Yw9RuPj
BETTER_AUTH_URL=http://localhost:3000
# PostgreSQL (Drizzle)
DATABASE_URL=postgresql://postgres:postgres@127.0.0.1:5432/postgres| Command | Description |
|---|---|
bun dev |
Start dev server with Turbopack |
bun build |
Build the project |
bun start |
Start production server |
bun auth:generate |
Generate Better Auth boilerplate |
bun db:push |
Push schema to DB |
bun db:migrate |
Run migrations |
bun db:introspect |
Introspect DB to schema |
bun db:generate |
Generate schema/migrations |
bun db:view |
Open Drizzle Studio |
bun db:drop |
Drop all DB tables |
bun lint |
Run Next.js lint |
bun lint:fix |
Fix lint errors |
bun lint:strict |
Fail on any warnings |
bun prepare |
Setup Husky Git hooks |
# Clone and install dependencies
git clone https://github.com/Chust3r/next-better-stack.git
cd next-better-stack
bun install
# Setup your .env
cp .env.example .env
# Generate auth files
bun auth:generate
# Push your database schema
bun db:push
# Start dev server
bun devβββ app/ # Next.js App Router directory (routes and pages)
βββ auth/ # Better Auth configuration and handlers
βββ components/ # Shared React components (UI, layout, etc.)
βββ config/ # Project-wide configuration (e.g., constants, env)
βββ database/ # Drizzle ORM schema definitions and database logic
βββ lib/ # Utility functions and reusable libraries
βββ server/ # TRPC routers and backend procedures
βββ types/ # Global TypeScript types
βββ middleware.ts # Next.js middleware for auth/session handling
βββ .env # Environment variables (not committed)
import { useTRPC } from '@components/providers/trpc-provider';
import { useQuery } from '@tanstack/react-query';
export default function HomePage() {
const trpc = useTRPC();
const { data, isLoading } = useQuery(trpc.example.getExample.queryOptions());
return <div>Home Page</div>;
}- Uses Prettier, ESLint, and Tailwind Prettier plugin
- Automatically formats staged files via lint-staged
- Fork & clone the repo
- Create a new branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -am 'Add my feature' - Push to branch:
git push origin feature/my-feature - Open a pull request π
This project is licensed under the MIT License - see the LICENSE file for details.