This project was created with a modern TypeScript stack that combines React, TanStack Router, Hono, tRPC, and more.
- TypeScript - For type safety and improved developer experience
- TanStack Router - File-based routing with full type safety
- TailwindCSS - Utility-first CSS for rapid UI development
- shadcn/ui - Reusable UI components
- Hono - Lightweight, performant server framework
- tRPC - End-to-end type-safe APIs
- Bun - Runtime environment
- Drizzle - TypeScript-first ORM
- SQLite/Turso - Database engine
- Authentication - Email & password authentication with Better Auth
- Biome - Linting and formatting
- Husky - Git hooks for code quality
First, install the dependencies:
bun installThis project uses SQLite with Drizzle ORM.
- Start the local SQLite database:
cd apps/server && bun db:local-
Update your
.envfile in theapps/serverdirectory with the appropriate connection details if needed. -
Apply the schema to your database:
bun db:pushThen, run the development server:
bun devOpen http://localhost:3001 in your browser to see the web application.
The API is running at http://localhost:3000.
Create a .env file in both apps/server and apps/web before starting the app. Below are working examples for local development.
CORS_ORIGIN=http://localhost:3001
# Generate a fresh 32‑byte secret for production (see next section)
BETTER_AUTH_SECRET=kgQjeoklizgXI6FdfANg9VNse0m0ma9E
BETTER_AUTH_URL=http://localhost:3000
DATABASE_URL=file:./local.dbVITE_SERVER_URL=http://localhost:3000Generate a cryptographically‑secure secret with OpenSSL:
# 32‑byte base64 string (recommended length for production)
openssl rand -base64 32Copy the output and paste it into the BETTER_AUTH_SECRET entry in your backend .env file.
Tip: Regenerate the secret when deploying to a different environment (staging, production, etc.) to isolate sessions across environments.
react-tanstack-router-hono-drizzle/
├── apps/
│ ├── web/ # Frontend application (React + TanStack Router)
│ └── server/ # Backend API (Hono, tRPC)
bun dev: Start all applications in development modebun build: Build all applicationsbun dev:web: Start only the web applicationbun dev:server: Start only the serverbun check-types: Check TypeScript types across all appsbun db:push: Push schema changes to databasebun db:studio: Open database studio UIcd apps/server && bun db:local: Start the local SQLite databasebun check: Run Biome formatting and linting