A production-ready starter template for React applications built with Vite, TypeScript, and Tailwind CSS v4. This template provides a modern development experience with file-based routing, type-safe environment variables, and comprehensive tooling for code quality and testing.
This template solves the problem of bootstrapping a modern React application with:
- Fast development: Vite-based HMR and build pipeline
- Type safety: Full TypeScript coverage with strict mode
- Routing: File-based routing via TanStack Router
- Styling: Tailwind CSS v4 with dark mode support
- State management: TanStack Query for server state
- Code quality: Biome for linting/formatting, TypeScript checking, and testing
- Developer experience: DevTools integration, environment validation, and PWA support
- Production-ready build configuration
- Type-safe environment variable validation
- File-based routing with code splitting
- Theme system with dark/light/system modes
- Testing setup with Vitest
- Git hooks for code quality enforcement
- Deployment configurations for Vercel, Netlify, and Cloudflare Workers
- Backend API implementation
- Authentication/authorization logic
- Database integration
- State management library (beyond TanStack Query)
- UI component library (beyond basic layout components)
graph TB
subgraph "Build Time"
A[Vite Config] --> B[TypeScript Compiler]
A --> C[Tailwind CSS v4]
A --> D[TanStack Router Plugin]
A --> E[React Compiler]
D --> F[Route Tree Generation]
end
subgraph "Runtime"
G[main.tsx] --> H[QueryClientProvider]
H --> I[RouterProvider]
I --> J[__root.tsx]
J --> K[Layout Component]
K --> L[ThemeProvider]
K --> M[Header/Footer]
J --> N[Route Components]
N --> O[Page Components]
end
subgraph "Development"
P[Vite Dev Server] --> Q[HMR]
R[Biome] --> S[Linting/Formatting]
T[Vitest] --> U[Test Runner]
V[Husky Hooks] --> W[Pre-commit Checks]
end
F --> I
B --> G
C --> G
| Module | Location | Responsibility |
|---|---|---|
| Routing | src/routes/ |
File-based route definitions, auto-generated route tree |
| Pages | src/lib/pages/ |
Page-level components organized by route |
| Layout | src/lib/layout/ |
Application shell (Header, Footer, Layout wrapper) |
| Components | src/lib/components/ |
Reusable UI components (ThemeProvider, ThemeToggle) |
| Services | src/lib/services/ |
Shared services and constants (QueryClient) |
| Utils | src/lib/utils/ |
Pure utility functions |
| Styles | src/lib/styles/ |
Global CSS and Tailwind configuration |
- React 19.2.0: UI library
- Vite 7.1.20 (rolldown-vite): Build tool and dev server
- TypeScript 5.9.3: Type system
- Tailwind CSS 4.1.17: Utility-first CSS framework
- TanStack Router 1.135.2: Type-safe file-based routing
- TanStack Query 5.90.7: Server state management
- Zod 4.1.12: Runtime type validation
- Biome 2.3.4: Linter and formatter (replaces ESLint/Prettier)
- Vitest 4.0.8: Test runner
- Husky 9.1.7: Git hooks
- Commitlint: Conventional commit validation
- Turbo: Task runner for parallel execution
@vitejs/plugin-react: React support with Fast Refresh@tanstack/router-plugin: File-based route generation@tailwindcss/vite: Tailwind CSS v4 integrationvite-plugin-pwa: PWA manifest and service worker@julr/vite-plugin-validate-env: Environment variable validationvite-plugin-checker: TypeScript checking in dev mode
vite-react-tailwind-starter/
├── src/
│ ├── lib/
│ │ ├── components/ # Reusable UI components
│ │ │ ├── theme-provider.tsx
│ │ │ └── theme-toggle.tsx
│ │ ├── layout/ # Layout components
│ │ │ ├── components/
│ │ │ │ ├── header.tsx
│ │ │ │ └── footer.tsx
│ │ │ └── index.tsx
│ │ ├── pages/ # Page components
│ │ │ ├── 404/
│ │ │ └── home/
│ │ ├── services/ # Shared services
│ │ │ └── constants.ts
│ │ ├── styles/ # Global styles
│ │ │ └── globals.css
│ │ └── utils/ # Utility functions
│ │ ├── sample.ts
│ │ └── sample.test.ts
│ ├── routes/ # TanStack Router routes
│ │ ├── __root.tsx # Root route with layout
│ │ └── index.tsx # Home route
│ ├── main.tsx # Application entry point
│ ├── routeTree.gen.ts # Auto-generated route tree
│ └── env.d.ts # Environment type definitions
├── public/ # Static assets
├── dist/ # Build output
├── vite.config.ts # Vite configuration
├── tsconfig.json # TypeScript configuration
├── biome.json # Biome linter/formatter config
├── vitest.config.ts # Vitest test configuration
├── env.ts # Environment variable schema
└── package.json
- Node.js: ^24.11.x (specified in
engines) - pnpm: 10.24.0 (specified in
packageManager)
You can either click Use this template button on this repository and clone the repo or use npx degit:
npx degit agustinusnathaniel/vite-react-tailwind-starter <app_name>
cd <app_name>
pnpm installStart the development server:
pnpm devThe application will be available at http://localhost:3000 with HMR enabled.
Build for production:
pnpm buildOutput will be in the dist/ directory.
Run tests:
pnpm test # Run tests once
pnpm test:ui # Run tests with UI and coverage
pnpm test:coverage # Run tests with coverage reportpnpm biome:check # Check code style and linting
pnpm biome:fix # Auto-fix code style issues
pnpm type:check # TypeScript type checking
pnpm check:turbo # Run all checks in parallel (biome, type, test)Environment variables are validated at build time using Zod. Define your schema in env.ts:
// env.ts
export default defineConfig({
schema: {
VITE_API_BASE_URL: z.string().optional(),
},
});Access variables in code with type safety:
import.meta.env.VITE_API_BASE_URLPath aliases are configured in tsconfig.json:
{
"paths": {
"@/*": ["./src/*"]
}
}Use in imports:
import { Layout } from '@/lib/layout';Tailwind CSS v4 is configured via the @tailwindcss/vite plugin. Global styles and customizations are in src/lib/styles/globals.css.
Routes are defined as files in src/routes/. TanStack Router automatically generates the route tree. See TanStack Router documentation for advanced patterns.
- Build command:
pnpm build - Output directory:
dist/ - Node version: ^24.11.x
- Vercel: https://vercel.com/docs/frameworks/vite
- Netlify: https://docs.netlify.com/frameworks/vite/
- Cloudflare Workers: Configuration in
wrangler.toml
- Create a file in
src/routes/(e.g.,src/routes/about.tsx) - Export a
RouteusingcreateFileRoute - The route tree will auto-regenerate
- Create directory in
src/lib/pages/(e.g.,src/lib/pages/about/) - Create
index.tsxwith your page component - Import and use in the corresponding route file
- Add schema definition in
env.ts - Create
.envfile with your variables (prefixed withVITE_) - Access via
import.meta.env.VITE_*with full type safety
- Pre-commit: Runs Biome formatting/linting on staged files
- Commit-msg: Validates commit message format (Conventional Commits)
- Pre-push: Runs full check suite (biome, type-check, tests)
See LICENSE file.