A production-ready React boilerplate with TypeScript, Vite, TanStack Router, TanStack Query, Zustand, and shadcn/ui. Built with modern best practices and scalable architecture patterns.
- β‘οΈ Vite - Lightning-fast development with HMR
- βοΈ React 19 - Latest React with concurrent features
- π― TypeScript - Full type safety across the stack
- π File-based Routing - Type-safe routing with TanStack Router
- π Data Fetching - TanStack Query for server state management
- π¨ shadcn/ui - Beautiful, accessible component library
- π Tailwind CSS - Utility-first styling with v4
- π TanStack Form - Type-safe forms with validation
- π Zustand - Lightweight global state management
- π Storybook - Component development and documentation
- π§ͺ Vitest - Fast unit testing
- π Playwright - End-to-end testing
- π ESLint - Code quality and consistency
- π Prettier - Code formatting
- πͺ Husky - Git hooks for quality gates
| Category | Technology |
|---|---|
| Core | React 19, TypeScript, Vite |
| Routing | TanStack Router (file-based) |
| Data Fetching | TanStack Query + Axios |
| State Management | Zustand |
| Forms | TanStack Form + Zod |
| UI Components | shadcn/ui + Radix UI |
| Styling | Tailwind CSS v4 |
| Icons | Tabler Icons + Lucide |
| Dev Tools | Storybook, Vitest, Playwright |
src/
βββ api/ # API client functions
βββ components/ # Reusable UI components
β βββ ui/ # shadcn/ui base components
β βββ core/ # App-level providers
β βββ layouts/ # Layout components
β βββ tanstack-form/# Form components
β βββ datatable/ # DataTable components
β βββ fallback/ # Loading/error states
βββ features/ # Feature-based modules
β βββ auth/ # Authentication feature
β βββ dashboard/ # Dashboard feature
β βββ posts/ # Posts feature
βββ hooks/ # Custom React hooks
βββ lib/ # Utility functions
βββ routes/ # File-based routing
β βββ __root.tsx # Root layout
β βββ (authenticated)/ # Protected routes
β βββ (unauthenticated)/ # Public routes
βββ stores/ # Zustand stores
βββ stories/ # Storybook stories
βββ types/ # Global TypeScript types
π For detailed folder explanations, see the README.md in each folder.
Features use separation of concerns:
- Container (
index.tsx): Data fetching, business logic - Presentational (
view.tsx): UI rendering, props-based
- Global components β
src/components/ - Feature-specific β
src/features/*/components/ - UI primitives β
src/components/ui/
- Server state β TanStack Query
- Global client state β Zustand
- Form state β TanStack Form
- URL state β TanStack Router
- Node.js 18+ and pnpm
# Clone the repository
git clone <repository-url>
cd react-boilerplate
# Install dependencies
pnpm install
# Start development server
pnpm dev# Development
pnpm dev # Start dev server (http://localhost:5173)
pnpm storybook # Start Storybook (http://localhost:6006)
# Build
pnpm build # Build for production
pnpm build-storybook # Build Storybook
# Code Quality
pnpm lint # Run ESLint
pnpm format # Format with Prettier
# Preview
pnpm preview # Preview production build-
Create feature folder:
src/features/tickets/ βββ list/ β βββ index.tsx # Container β βββ view.tsx # Presentational β βββ data.tsx # TanStack Query hooks β βββ types.d.ts # Types β βββ components/ # Feature-specific components βββ create/ βββ details/ -
Add API calls:
// src/api/tickets.ts export const ticketApi = { getAll: () => api.get<Ticket[]>('/tickets'), create: (data) => api.post('/tickets', data), };
-
Create route:
// src/routes/(authenticated)/tickets/index.lazy.tsx import { createLazyFileRoute } from '@tanstack/react-router'; import TicketsList from '@/features/tickets/list'; export const Route = createLazyFileRoute('/(authenticated)/tickets/')({ component: TicketsList, });
// src/stores/my-store.ts
import { create } from 'zustand';
export const useMyStore = create<State & Actions>((set) => ({
count: 0,
increment: () => set((s) => ({ count: s.count + 1 })),
}));
// In component
const count = useMyStore((s) => s.count);// schema.ts
import { z } from 'zod';
export const loginSchema = z.object({
email: z.string().email(),
password: z.string().min(8),
});
export const defaultValues = {
email: '',
password: '',
};- Folder Structure: See README.md files in each
src/subfolder - Component Stories: Run
pnpm storybookand check "Stories Overview" - API Reference: Check inline JSDoc comments
- Follow the established folder structure
- Use TypeScript for type safety
- Write Storybook stories for new components
- Keep features self-contained
- Update relevant README files
- TypeScript: Strict mode enabled
- Naming: PascalCase for components, camelCase for functions
- Imports: Use
@/alias for absolute imports - Components: Prefer named exports
- Formatting: Prettier runs on commit via Husky
vite.config.ts- Vite configurationeslint.config.js- ESLint rulestsconfig.json- TypeScript compiler optionstailwind.config.js- Tailwind customizationcomponents.json- shadcn/ui configuration
MIT
Built with amazing tools from: