Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/amanvarshney01/create-better-t-stack/llms.txt

Use this file to discover all available pages before exploring further.

Overview

Better-T-Stack includes ready-to-use example applications that demonstrate best practices and common patterns. These examples are fully integrated with your chosen stack and provide working code you can learn from or build upon.

Available examples

Todo app

A complete CRUD (Create, Read, Update, Delete) application demonstrating:
  • Database operations with your chosen ORM
  • Type-safe API calls with tRPC or oRPC
  • Form handling and validation
  • Optimistic updates
  • Error handling
  • UI components with shadcn/ui (if applicable)
Includes:
  • Backend API routes for todo operations
  • Frontend UI with create/edit/delete functionality
  • Database schema and migrations
  • Type-safe client-server communication
Location in generated project:
Web:
- apps/web/src/routes/todo/ (TanStack Router)
- apps/web/src/app/todo/ (Next.js)
- apps/web/src/routes/todo/ (SvelteKit)
- etc.

Server:
- apps/server/src/routes/todo/ (Hono/Express/Fastify/Elysia)

Database:
- packages/db/src/schema/todo.ts (schema)

AI chat app

An AI-powered chat interface demonstrating:
  • Streaming responses from AI models
  • Real-time UI updates
  • Message history management
  • Error handling and retry logic
  • Integration with AI providers (OpenAI, Anthropic, etc.)
Includes:
  • Backend endpoint for AI streaming
  • Frontend chat UI with message bubbles
  • Streaming response handling
  • Loading states and animations
Location in generated project:
Web:
- apps/web/src/routes/ai/ (TanStack Router)
- apps/web/src/app/ai/ (Next.js)
- apps/web/app/(drawer)/ai.tsx (React Native)
- etc.

Server:
- apps/server/src/routes/ai/ (server-based backends)
- apps/web/src/app/api/ai/ (Next.js API routes)
- packages/backend/convex/agent.ts (Convex)

Adding examples to your project

During project creation

Include examples when scaffolding your project:
npm create better-t-stack@latest my-app \
  --frontend tanstack-router \
  --backend hono \
  --database sqlite \
  --orm drizzle \
  --examples todo ai

Via interactive prompts

When running the CLI without flags, you’ll be asked:
? Include example apps? › - Space to select. Return to submit
  ○ Todo (CRUD example)
  ○ AI (AI chat example)
Select examples with Space and confirm with Enter.

After project creation

Examples cannot be added after project creation via the add command. They must be included during initial scaffolding.
If you need examples after creation:
  1. Create a new project with examples included
  2. Copy the relevant files to your existing project
  3. Adjust imports and paths as needed

Example requirements

Todo app requirements

Required:
  • Database (any: SQLite, PostgreSQL, MySQL, MongoDB)
  • ORM (any: Drizzle, Prisma, Mongoose)
  • Backend (any except None)
Optional but recommended:
  • API layer (tRPC or oRPC) for type-safe communication
If no database/ORM is configured, the Todo example is skipped automatically.

AI app requirements

Required:
  • Backend (any except None)
No database required - the AI example works without persistent storage. Environment variables needed: For AI examples, you’ll need an API key from your chosen provider:
# OpenAI
OPENAI_API_KEY=sk-...

# Anthropic
ANTHROPIC_API_KEY=sk-ant-...

# Or other providers
Check the generated code comments for specific provider setup.

Stack-specific implementations

Examples adapt to your chosen stack:

Frontend implementations

Examples use file-based routing:
apps/web/src/routes/
  todo/
    index.tsx (list view)
    $todoId.tsx (detail view)
  ai/
    index.tsx (chat interface)

Backend implementations

// apps/server/src/routes/todo/index.ts
import { Hono } from "hono";
import { db } from "@my-app/db";
import { todos } from "@my-app/db/schema";

const app = new Hono()
  .get("/", async (c) => {
    const allTodos = await db.select().from(todos);
    return c.json(allTodos);
  })
  .post("/", async (c) => {
    const body = await c.req.json();
    const [todo] = await db.insert(todos).values(body).returning();
    return c.json(todo, 201);
  });

export default app;

ORM-specific code

Examples use your chosen ORM:
// packages/db/src/schema/todo.ts
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";

export const todos = sqliteTable("todos", {
  id: integer("id").primaryKey({ autoIncrement: true }),
  text: text("text").notNull(),
  completed: integer("completed", { mode: "boolean" }).notNull().default(false),
  createdAt: integer("created_at", { mode: "timestamp" }).notNull().$defaultFn(() => new Date()),
});

Using examples

Running the examples

After project creation with examples:
1

Install dependencies

bun install  # or npm install, pnpm install
2

Set up database

For Todo example:
bun run db:push  # Apply schema to database
3

Add environment variables

For AI example, add your API key:
# apps/server/.env
OPENAI_API_KEY=sk-...
4

Start development

bun run dev
5

Visit example pages

  • Todo: http://localhost:3000/todo
  • AI: http://localhost:3000/ai

Learning from examples

Examples demonstrate: API design patterns:
  • RESTful routes (GET, POST, PUT, DELETE)
  • Request validation
  • Error handling
  • Response formatting
Database patterns:
  • Schema definitions
  • Migrations
  • Queries and mutations
  • Relationships (if applicable)
Frontend patterns:
  • Data fetching
  • Form handling
  • Optimistic updates
  • Loading states
  • Error boundaries
Type safety:
  • Shared types between client and server
  • Zod validation schemas
  • tRPC or oRPC procedures

Customizing examples

Examples are meant to be modified:
  1. Use as templates - Copy example patterns for new features
  2. Extend functionality - Add fields, features, or endpoints
  3. Remove if not needed - Delete example code once you’ve learned from it
The Todo example is especially useful as a template for other CRUD features. Copy its structure for users, posts, products, etc.

Source code

Example templates are located in the Better-T-Stack repository:
packages/template-generator/templates/examples/
  todo/
    frontend/  (frontend-specific UI)
    server/    (server-specific routes)
    native/    (React Native screens)
  ai/
    frontend/  (chat UI)
    server/    (streaming endpoints)
    native/    (React Native chat)
View the source: github.com/amanvarshney01/create-better-t-stack

Next steps

Database setup

Configure your database provider

Project structure

Understand the generated project layout

Deployment

Deploy your project to production

Add command

Add more features after creation

Build docs developers (and LLMs) love