An opinionated full-stack starter template built on TanStack Start with authentication plumbing, database access, type-safe APIs, and UI components pre-configured.
- Framework: TanStack Start (React 19, SSR, file-based routing)
- API: oRPC (type-safe RPC with TanStack Query integration)
- Auth: Better Auth (session/database wiring included; choose and enable your auth methods as needed)
- Database: Drizzle ORM + PostgreSQL
- Cache/infra: Redis is included as an optional local service for future caching, queues, rate limiting, or Better Auth secondary storage
- UI: shadcn/ui + Tailwind CSS v4
- Validation: Zod + t3-env for type-safe env vars
- Testing: Vitest + Testing Library
- Tooling: ESLint, Prettier, TypeScript
bunx degit kddige/tanstack-starter-template my-app
cd my-app
bun installcp .env.example .envEdit .env with your values:
# Generate a strong Better Auth secret
bunx --bun @better-auth/cli secret
# Default local PostgreSQL URL for docker-compose.yml
DATABASE_URL="postgres://postgres:postgres@localhost:5432/postgres"A docker-compose.yml is included with PostgreSQL and Redis services matching the default .env.example values.
docker compose up -dRedis is optional infrastructure for common app needs such as caching, queues, rate limiting, or Better Auth secondary storage. If you do not need it, remove the Redis service from docker-compose.yml, the redis dependency, and REDIS_URL from .env.example and src/env.ts.
bun run db:push # Push schema directly to the database for local development
# or
bun run db:migrate # Run generated migrations for production-like environmentsUse db:push only for local prototyping where data loss is acceptable. For production-bound schema changes, generate and review migrations with bun run db:generate, then apply them with bun run db:migrate.
bun run devOpen http://localhost:3000.
| Script | Description |
|---|---|
bun run dev |
Start dev server on port 3000 |
bun run build |
Production build |
bun run preview |
Preview production build |
bun run test |
Run tests with Vitest |
bun run test:watch |
Run tests in watch mode |
bun run lint |
Lint with ESLint |
bun run typecheck |
Type-check with TypeScript |
bun run format |
Check formatting with Prettier |
bun run check |
Fix formatting + lint |
bun run verify |
Run format, lint, typecheck, and tests |
bun run db:generate |
Generate Drizzle migrations |
bun run db:migrate |
Run Drizzle migrations |
bun run db:push |
Push schema directly to database |
bun run db:studio |
Open Drizzle Studio |
bun run auth:generate |
Regenerate Better Auth Drizzle schema |
All env vars are validated at runtime through src/env.ts using @t3-oss/env-core. Add new variables there before using them.
import { env } from '#/env'
// Server-side
env.REDIS_URL
env.DATABASE_URL
env.BETTER_AUTH_SECRET
env.BETTER_AUTH_URL
// Client-side (must be prefixed with VITE_)
env.VITE_APP_TITLEBetter Auth is configured with Drizzle as the database adapter and TanStack Start cookie support. The auth server is in src/server/lib/auth.ts and the client is in src/lib/auth-client.ts.
No sign-in method is enabled by default. Enable the auth method your app needs, such as email/password, OAuth providers, passkeys, or 2FA, then regenerate the schema if the config changes database tables:
bun run auth:generateSee the Better Auth docs for adding email/password, OAuth providers, 2FA, and more.
Drizzle ORM is configured with PostgreSQL. Application schemas live in src/server/lib/db/schemas/app-schema.ts. Better Auth generated schemas live in src/server/lib/db/schemas/auth-schema.ts.
docker compose up -d # Start PostgreSQL and Redis
bun run db:generate # Generate migration files
bun run db:migrate # Apply migrations
bun run db:studio # Visual database browserThese aren't included in the template but are recommended for common needs:
- React Hook Form — Performant form handling with validation. Pairs well with Zod for schema-based validation via
@hookform/resolvers. - TanStack Pacer — Rate-limiting, throttling, and debouncing primitives. Useful for search inputs, API call protection, and preventing excessive user actions.
MIT