GitHunt
MA

masrurimz/tanstack-start-elysia-better-auth-bun

Full-stack monorepo template with TanStack Start, Elysia.js, and Better Auth. Features end-to-end type safety, blazing performance, and seamless authentication. Perfect starting point for modern web applications.

TanStack Start + Elysia + Better Auth Template

A full-stack monorepo template showcasing the power of modern web development with end-to-end type safety, blazing performance, and seamless authentication.

๐Ÿš€ Motivation

This project was inspired by Indra Zulfi Mushoddaq's post about the incredible developer experience of Elysia + Eden + Better Auth combination. After trying it out, I can confirm that this stack is absolutely GOAT (Greatest Of All Time):

โœ… Auto-generated docs - No more manual API documentation headaches
โœ… E2E Type Safety - Thanks to Eden Client + Better Auth Client
โœ… Performance fast AF - Even faster than server functions from Remix, Next.js, or TanStack Start
โœ… Auth setup made easy - From Social Sign-In to email+password (Indonesian favorite +62)

The SSR works smoothly and is surprisingly easier to configure than Remix and Start.

๐Ÿ—๏ธ What's inside?

This monorepo includes the following packages/apps:

Apps and Packages

  • backend: Elysia.js API server with Better Auth
  • web: TanStack Start frontend with SSR
  • packages/db: Drizzle ORM with SQLite/Turso database
  • packages/backend-client: Type-safe API client using Eden Treaty
  • tooling/*: Shared configurations (ESLint, Prettier, TypeScript, Tailwind)

Tech Stack

  • Frontend: TanStack Start, TanStack Query, Jotai, shadcn/ui
  • Backend: Elysia.js, Better Auth, Swagger docs
  • Database: Drizzle ORM, SQLite/Turso
  • Runtime: Bun
  • Styling: Tailwind CSS
  • Type Safety: End-to-end with Eden Treaty

Getting Started

To install and start developing all apps, run the following command:

bun install
bun dev

Development Scripts

# Type check all packages
bun typecheck

# Format all packages
bun format
bun format:fix

# Lint all packages
bun lint
bun lint:fix

# Database operations
bun db:generate    # Generate migrations
bun db:push       # Push schema to database
bun db:seed       # Seed database with sample data
bun db:studio     # Open Drizzle Studio

# Build and clean
bun build         # Build all packages
bun clean         # Clean all artifacts

๐Ÿ›๏ธ Architecture

This template follows clean architecture principles with feature-based organization:

Monorepo Structure

apps/
โ”œโ”€โ”€ backend/          # Elysia.js API server
โ””โ”€โ”€ web/              # TanStack Start frontend
packages/
โ”œโ”€โ”€ backend-client/   # Type-safe API client (Eden Treaty)
โ””โ”€โ”€ db/              # Drizzle ORM schemas and migrations
tooling/             # Shared configs (ESLint, Prettier, TypeScript, Tailwind)

Key Features Implemented

  • ๐Ÿ” Authentication: Complete flow with Better Auth (email/password + social)
  • ๐Ÿ“Š Count Demo: File-based persistence example
  • ๐Ÿ’ฌ Messages: Full CRUD operations with database
  • ๐ŸŽฎ Pokemon: External API integration with caching
  • ๐Ÿ“š Auto Docs: Swagger documentation generation
  • ๐Ÿ”„ SSR: Server-side rendering with TanStack Start

๐ŸŒŸ What Makes This Stack Special

  1. End-to-End Type Safety: From database to frontend, everything is typed
  2. Performance: Bun runtime + Elysia performance + TanStack optimizations
  3. Developer Experience: Hot reload, auto-completion, built-in docs
  4. Modern Patterns: Clean architecture, repository pattern, feature organization
  5. Production Ready: Auth, database, error handling, and deployment ready

๐Ÿค Contributing

This is a demonstration template, but feel free to:

  • Open issues for bugs or suggestions
  • Submit PRs for improvements
  • Use this as a starting point for your projects

๐Ÿ™ Acknowledgments

  • Thanks to Indra Zulfi Mushoddaq for the inspiration
  • The amazing teams behind Elysia, TanStack, and Better Auth
  • The TypeScript and Bun communities

Sorry for messy code ๐Ÿ™ƒ, but if you have suggestions, feel free to share!

Want to discuss minimal features or UI improvements? Drop a comment in the discussions! ๐Ÿš€

masrurimz/tanstack-start-elysia-better-auth-bun | GitHunt