TanStack Start + Hono Full-Stack Architecture
TanStack Start is a full-stack React framework with SSR, file-based routing, and server functions. Hono is an ultrafast, lightweight web framework that runs on any JavaScript runtime. Combining them in a monorepo gives you a modern, type-safe full-stack stack.badmin
Admin panel — TanStack Start + Hono + Drizzle + SQLite.
cyop
AI captioning platform — TanStack Router + Hono + tRPC + Drizzle + Postgres.
Architecture Overview
Frontend: TanStack Start
TanStack Start provides file-based routing with@tanstack/react-router, SSR via Vinxi, and full-stack server functions.
Key Setup
Route Configuration
Server Functions
TanStack Start supports server-side functions that run only on the server:Backend: Hono
Hono is the API layer — fast, type-safe, and runtime-agnostic. It handles auth, CRUD, and business logic.Basic Server Setup
Service Pattern
Use factory functions for dependency injection:Factory functions (
createXxxService) give you explicit dependency injection without class boilerplate. Each service receives its dependencies as parameters, making testing trivial — just pass mock implementations.Session Cookie Auth
Instead of JWT tokens, use signed session cookies for simplicity and security:Localized Error Responses
For bilingual apps, return locale-aware error messages from the API:Styling: UnoCSS
For TanStack Start projects, UnoCSS is lighter and faster than Tailwind for utility classes:Use
presetWind4 for Tailwind CSS 4-compatible utilities. Use presetIcons for FontAwesome/Material icon classes without importing SVGs.Best Practices
- Monorepo with shared contracts — Put Zod schemas and tRPC routers in a shared package so frontend and backend stay type-synced
- Factory-function services — Prefer
createAuthService(opts)overclass AuthServicefor explicit DI - Signed cookie sessions — Simpler than JWT, revocable by bumping
sessionVersion - Server functions for secrets — Never expose API keys or DB queries in client code
- Locale-aware errors — Frontend sends
X-Locale, server returns localized keys - UnoCSS over Tailwind — Faster build, icon presets, and Tailwind-compatible utilities
References
- TanStack Start Docs
- Hono Docs
- badmin repo — working admin panel with this stack
- cyop repo — AI captioning platform
