A modern, production-ready React starter template built with Vite, TanStack Router, TanStack Query, shadcn/ui, and Tailwind CSS v4.
- React 19 - UI library
- TypeScript - Type safety
- Vite - Build tool and dev server
- TanStack Router - Type-safe routing
- TanStack Query - Powerful data synchronization
- shadcn/ui - Composable component library
- Tailwind CSS v4 - Utility-first CSS framework
- Zod v4 - TypeScript-first schema validation
- ky - Elegant HTTP client
- orval - OpenAPI client generator (React Query hooks, TypeScript types, Zod schemas, MSW mocks)
- MSW - API mocking for tests and development
- lint-staged - Auto-format staged files on commit
- β‘οΈ Lightning-fast HMR with Vite
- π― Type-safe routing with TanStack Router
- π Powerful async state management with TanStack Query
- π Auto-generated API client from OpenAPI specs via orval
- β Runtime validation with Zod
- π¨ Beautiful, accessible components with shadcn/ui
- π§ Utility-first styling with Tailwind CSS v4
- π¦ Production-ready build configuration
- π Optimized for modern development workflow
- Node.js 24+
- pnpm
# Clone the repository
git clone https://github.com/yourusername/your-repo-name.git
cd your-repo-name
# Install dependencies
pnpm install
# (Optional) Generate API client
# Requires a running backend with an OpenAPI spec; you can skip this for now
# and run it later once your backend is up (see "API Client Generation" section).
pnpm generate-apipnpm devOpen http://localhost:5173 in your browser.
pnpm buildpnpm previewThis template uses orval to generate type-safe React Query hooks from your backend's OpenAPI specification.
# Start your backend server first, then:
pnpm generate-apiThis generates:
- React Query hooks (
useQuery/useMutation) insrc/api/generated/hooks/- with integrated Zod validation - TypeScript types for all request/response schemas in
src/api/generated/types/ - Standalone Zod schemas in
src/api/generated/zod/(for form validation, manual use) - MSW mock handlers for testing in
src/api/generated/mocks/
The orval configuration is in orval.config.ts. By default, it fetches the OpenAPI spec from http://localhost:8000/openapi.json.
For CI/CD, set the OPENAPI_URL repository variable to point to your staging/dev backend. The CI workflow will verify that generated types are up-to-date.
After generating, import hooks and schemas from src/api/generated/. The generated code is organized by API tags.
React Query hooks (with automatic Zod validation):
// Import generated hooks (paths depend on your API's tags and endpoints)
import { useGetUsers, useCreateUser } from "@/api/generated/hooks/users/users"
function UserList() {
// Responses are automatically validated with Zod
// Invalid responses will throw a ZodError
const { data, isLoading, error } = useGetUsers()
if (isLoading) return <div>Loading...</div>
if (error) return <div>Error: {error.message}</div>
// Response structure depends on your OpenAPI spec
return <pre>{JSON.stringify(data, null, 2)}</pre>
}Standalone Zod schemas (for form validation, etc.):
// Import standalone Zod schemas for manual validation
import { CreateUserBody } from "@/api/generated/zod/users/users"
// Validate form data before submitting
const result = CreateUserBody.safeParse(formData)
if (!result.success) {
console.error(result.error.issues)
}Note: The exact imports and response structures depend on your backend's OpenAPI specification. Check the generated files in
src/api/generated/after runningpnpm generate-api.
βββ src/
β βββ api/ # API client, handlers, and endpoint definitions
β β βββ api.ts # ky client configuration
β β βββ orval-client.ts # Custom adapter for orval (uses ky)
β β βββ generated/ # Auto-generated (do not edit)
β β β βββ hooks/ # React Query hooks
β β β βββ types/ # TypeScript types
β β β βββ zod/ # Zod schemas
β β β βββ mocks/ # MSW mock handlers
β β βββ handlers.ts # MSW handlers aggregator
β βββ components/ # Reusable React components
β β βββ ui/ # Installed shadcn/ui components
β βββ pages/ # Page components
β βββ routes/ # TanStack Router routes
β βββ lib/ # Utility functions
β βββ test/ # Test setup and utilities
β βββ main.tsx # Application entry point
βββ public/ # Static assets
βββ package.json
This template uses shadcn/ui. To add new components:
npx shadcn-ui@latest add button
npx shadcn-ui@latest add card
# etc.Pre-configured for efficient server state management:
import { useQuery } from "@tanstack/react-query"
const { data, isLoading } = useQuery({
queryKey: ["todos"],
queryFn: fetchTodos,
})Type-safe routing with automatic code splitting:
import { createFileRoute } from "@tanstack/react-router"
export const Route = createFileRoute("/about")({
component: About,
})Runtime type validation for forms and API responses:
import { z } from "zod"
const UserSchema = z.object({
name: z.string(),
email: z.string().email(),
})This project is licensed under the Apache 2.0 License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.