A full-stack React template for building type-safe TaylorDB applications with TanStack Start, TanStack Router, Tailwind CSS, and shadcn/ui.
This template replaces the older React Router SPA + Express/tRPC split used by the legacy TaylorDB full-stack template with a single TanStack Start app. TaylorDB access runs on the server through TanStack Start server functions or server routes.
- TanStack Start: SSR, routing, server functions, server routes, and Nitro output.
- Type-safe TaylorDB access:
@taylordb/query-builderwith generated schema types. - Server-only data layer: database calls live in
src/server/**, never in client components. - Modern UI: Tailwind CSS 4 and shadcn/ui components in
src/components/ui. - AI-ready conventions:
AGENTS.mdexplains where agents should put routes, server functions, repositories, and TaylorDB helpers.
pnpm install
pnpm devBuild for production:
pnpm build
node .output/server/index.mjstaylordb-tanstack-template/
βββ src/
β βββ routes/ # TanStack Router file routes
β β βββ __root.tsx # Root document shell
β β βββ index.tsx # Home route
β β βββ $.tsx # Catch-all 404 route
β βββ components/
β β βββ ui/ # shadcn/ui components
β β βββ Header.tsx
β β βββ ThemeToggle.tsx
β βββ lib/
β β βββ utils.ts # shadcn cn() helper
β βββ server/ # Recommended server-only TaylorDB code
β β βββ taylordb.ts # create per-request query builder
β β βββ repositories/ # table-level query functions
β β βββ services/ # business logic across repositories
β β βββ *.functions.ts # createServerFn operations
β βββ routeTree.gen.ts # generated by TanStack Router
β βββ router.tsx
β βββ styles.css # Tailwind + design tokens
βββ docs/ # shadcn and TaylorDB/TanStack guides
βββ components.json # shadcn config
βββ package.json
βββ vite.config.tssrc/server/** is the recommended location for TaylorDB code. The template may
not include generated TaylorDB schema types until you connect a TaylorDB base and
run the schema generator.
- React 19
- TanStack Start
- TanStack Router
- Nitro output
- Vite 8
- TypeScript
- TaylorDB Query Builder (
@taylordb/query-builder) - Generated
TaylorDatabaseschema types - TanStack Start server functions for app-facing data operations
- TanStack Start server routes for raw HTTP endpoints and multipart/form-data
- Tailwind CSS 4
- shadcn/ui
- Radix UI primitives through the shadcn registry
- Lucide icons
TanStack Start does not need Express or tRPC for normal app data access. Use:
- Server functions for typed reads and mutations called from loaders/components.
- Server routes for raw HTTP APIs, webhooks, or file upload endpoints.
- A server-only TaylorDB helper that reads the
app_access_tokencookie per request and constructs a fresh query builder.
Example helper:
// src/server/taylordb.ts
import { createQueryBuilder } from "@taylordb/query-builder";
import { getRequestHeader } from "@tanstack/react-start/server";
import type { TaylorDatabase } from "./taylordb/types";
function readCookie(name: string) {
const header = getRequestHeader("cookie");
if (!header) return null;
for (const part of header.split(/;\s*/)) {
const eq = part.indexOf("=");
if (eq === -1) continue;
if (part.slice(0, eq) === name) return decodeURIComponent(part.slice(eq + 1));
}
return null;
}
export function getTaylorDB() {
const appAccessToken = readCookie("app_access_token");
if (!appAccessToken) throw new Error("Unauthorized");
return createQueryBuilder<TaylorDatabase>({
baseUrl: process.env.TAYLORDB_BASE_URL!,
baseId: process.env.TAYLORDB_SERVER_ID!,
apiKey: appAccessToken,
});
}Example server function:
// src/server/users.functions.ts
import { createServerFn } from "@tanstack/react-start";
import { z } from "zod";
import { getTaylorDB } from "./taylordb";
export const getUsers = createServerFn({ method: "GET" }).handler(async () => {
const qb = getTaylorDB();
return qb
.selectFrom("users")
.select(["id", "name", "email"])
.execute();
});
export const createUser = createServerFn({ method: "POST" })
.inputValidator(z.object({ name: z.string().min(1), email: z.string().email() }))
.handler(async ({ data }) => {
const qb = getTaylorDB();
return qb
.insertInto("users")
.values(data)
.returning(["id", "name", "email"])
.executeTakeFirst();
});Example route loader:
// src/routes/users.tsx
import { createFileRoute } from "@tanstack/react-router";
import { getUsers } from "@/server/users.functions";
export const Route = createFileRoute("/users")({
loader: () => getUsers(),
component: UsersPage,
});
function UsersPage() {
const users = Route.useLoaderData();
return <pre>{JSON.stringify(users, null, 2)}</pre>;
}Use server routes when you need the raw Request object, a plain JSON endpoint,
webhooks, or multipart form parsing:
// src/routes/api/users.ts
import { createFileRoute } from "@tanstack/react-router";
import { getTaylorDB } from "@/server/taylordb";
export const Route = createFileRoute("/api/users")({
server: {
handlers: {
GET: async () => {
const qb = getTaylorDB();
const users = await qb.selectFrom("users").select(["id", "name"]).execute();
return Response.json(users);
},
POST: async ({ request }) => {
const formData = await request.formData();
const qb = getTaylorDB();
const file = formData.get("avatar");
const attachments =
file instanceof File
? await qb.uploadAttachments([{ file, name: file.name }])
: [];
return Response.json({ uploaded: attachments.length });
},
},
},
});TaylorDB server-side code expects:
TAYLORDB_BASE_URLTAYLORDB_SERVER_ID
The TaylorDB login flow must set an HttpOnly app_access_token cookie. Server
functions and server routes read this cookie on each request.
pnpm dlx shadcn@latest add button card input label textarea alert tabs select dropdown-menuDo not add "use client" directives to app files. TanStack Start is not Next.js.
If the shadcn registry inserts "use client", remove it from files under src/.
- AGENTS.md: implementation rules for AI agents.
- docs/TAYLORDB_TANSTACK_START.md: TaylorDB with TanStack Start guide.
- docs/SHADCN_COMPONENTS_GUIDE.md: shadcn component notes.
- TanStack Start server functions
- TanStack Start authentication server primitives
MIT
A production-ready template for building modern, type-safe web applications with TaylorDB. Designed for AI-assisted development with comprehensive documentation and best practices built-in.
- Full-Stack Setup: React frontend + Node.js backend in a monorepo
- Type Safety: End-to-end TypeScript from database to UI
- Modern UI: shadcn/ui components with Tailwind CSS
- Type-Safe API: tRPC for seamless client-server communication
- TaylorDB Integration: Query builder with generated types
- AI-Ready: Comprehensive documentation for AI-assisted development
pnpm installtaylordb-fullstack-template/
βββ apps/
β βββ client/ # React frontend (Vite)
β β βββ src/
β β β βββ components/ui/ # shadcn/ui components
β β β βββ pages/ # Route pages
β β β βββ lib/ # Utilities & tRPC client
β β β βββ index.css # Design tokens
β β βββ package.json
β β
β βββ server/ # Node.js backend
β βββ taylordb/
β β βββ types.ts # Generated schema types
β β βββ query-builder.ts # Database operations
β βββ router.ts # tRPC API routes
β βββ package.json
β
βββ docs/ # Comprehensive guides
β βββ TAYLORDB_QUERY_REFERENCE.md
β βββ SHADCN_COMPONENTS_GUIDE.md
β
βββ AGENTS.md # AI agent instructions
βββ taylordb.yml # Deployment config
This template includes comprehensive documentation for both human and AI developers:
- AGENTS.md: Complete AI agent instructions
- Development workflow (Planning β Execution β Verification)
- Design guidelines for modern UIs
- Code organization best practices
- Type safety patterns
- Example implementations
-
docs/TAYLORDB_QUERY_REFERENCE.md: Query builder reference
- All CRUD operations with examples
- Field type handling
- Advanced patterns (aggregations, pagination)
- Common pitfalls and solutions
-
docs/SHADCN_COMPONENTS_GUIDE.md: UI component guide
- Dashboard patterns
- Form examples
- Data tables
- Responsive design tips
- React 19 with TypeScript
- Vite 7 for fast builds
- TailwindCSS 4 for styling
- shadcn/ui for UI components
- React Router v6 for routing
- tRPC React Query for API calls
- Node.js with TypeScript
- Express 5 web server
- tRPC 11 for type-safe APIs
- Zod for validation
- TaylorDB Query Builder for database
// Backend defines the API
export const appRouter = router({
users: {
getById: publicProcedure
.input(z.object({ id: z.number() }))
.query(async ({ input }) => { ... }),
},
});
// Frontend gets full autocomplete
const { data: user } = trpc.users.getById.useQuery({ id: 1 });
// ^? User | undefined (fully typed!)All components from shadcn/ui with:
- Full dark mode support
- Responsive design
- Accessible by default
- Customizable with Tailwind
Type-safe queries with TaylorDB:
// Auto-generated types from your schema
export async function getAllUsers() {
return await queryBuilder
.selectFrom("users")
.select(["id", "name", "email"])
.execute();
}This template is optimized for AI-assisted development:
- Read AGENTS.md: Comprehensive instructions for AI agents
- Follow the workflow: Planning β Execution β Verification
- Use type safety: All examples use strict TypeScript
- Reference docs: Query patterns, component examples, best practices
The AI agent will:
- Understand your TaylorDB schema
- Design appropriate color schemes
- Build type-safe CRUD operations
- Create modern, responsive UIs
- Follow best practices automatically
This template is designed to deploy to TaylorDB's platform using the included taylordb.yml configuration.
Environment Variables Required:
TAYLORDB_BASE_URLTAYLORDB_SERVER_ID
- Create database functions in
apps/server/taylordb/query-builder.ts - Expose via tRPC in
apps/server/router.ts - Build UI in
apps/client/src/pages/ - Add route in
apps/client/src/main.tsx
pnpm dlx shadcn@latest add <component-name>Example:
pnpm dlx shadcn@latest add table dialog toastEdit apps/client/src/index.css to change colors, fonts, and spacing.
- shadcn/ui: https://ui.shadcn.com/
- tRPC: https://trpc.io/
- TaylorDB: https://taylordb.ai/
- Tailwind CSS: https://tailwindcss.com/
MIT - Use freely for any project!
Built for modern, type-safe full-stack development with AI assistance β¨