A modern, production-ready React boilerplate with TypeScript, designed for projects of all scales - from small apps to enterprise applications.
- React 19 - Latest React with all modern features
- TypeScript - Type safety with strict mode enabled
- Vite - Lightning-fast build tool and dev server
- pnpm - Efficient package management
- Zustand - Lightweight, modern state management
- TanStack Query (React Query) - Powerful async state management
- Server state and client state separation
- React Router v7 - Client-side routing
- Lazy loading for optimal performance
- Protected routes pattern included
- Tailwind CSS - Utility-first CSS framework
- CSS Variables - Custom design tokens
- Dark mode support built-in
- Responsive design utilities
- React Hook Form - Performant forms with minimal re-renders
- Zod - TypeScript-first schema validation
- Form examples included
- Vitest - Fast, Vite-native unit testing
- React Testing Library - Component testing best practices
- Playwright - Reliable E2E testing
- MSW - API mocking
- ESLint - Code linting with React and TypeScript rules
- Prettier - Consistent code formatting
- Husky - Git hooks
- lint-staged - Run linters on staged files
- Commitlint - Conventional commit messages
- Docker - Containerization ready
- GitHub Actions - CI/CD pipeline
- Nginx - Production server configuration
- Environment-based configuration
- Hot Module Replacement (HMR)
- TypeScript path aliases
- VS Code settings included
- Recommended extensions
- react-i18next - Multi-language support
- Language detection
- Translation examples
- Error boundaries
- Loading states
- 404 page
- API client with interceptors
- Custom hooks library
- Utility functions
react-boilerplate/
βββ .github/
β βββ workflows/ # GitHub Actions CI/CD
βββ .vscode/ # VS Code settings
βββ e2e/ # Playwright E2E tests
βββ public/ # Static assets
βββ src/
β βββ components/
β β βββ ui/ # Reusable UI components (Button, Input, Card, etc.)
β β βββ layout/ # Layout components (Header, Footer, Layout)
β β βββ common/ # Common components (LoadingSpinner, ErrorFallback)
β βββ features/ # Feature-based modules (future features go here)
β βββ pages/ # Route pages (HomePage, AboutPage, NotFoundPage)
β βββ hooks/ # Custom React hooks
β β βββ useDebounce.ts
β β βββ useLocalStorage.ts
β β βββ useMediaQuery.ts
β βββ stores/ # Zustand stores
β β βββ themeStore.ts
β β βββ userStore.ts
β βββ services/ # API services
β β βββ apiClient.ts
β β βββ postService.ts
β βββ utils/ # Utility functions
β β βββ helpers.ts
β βββ types/ # TypeScript type definitions
β βββ config/ # App configuration
β β βββ env.ts
β β βββ i18n.ts
β βββ assets/ # Images, icons, etc.
β βββ tests/ # Test utilities and setup
β βββ App.tsx # Main App component
β βββ main.tsx # Entry point
β βββ index.css # Global styles
βββ .env.example # Environment variables example
βββ .eslintrc.js # ESLint configuration
βββ .prettierrc # Prettier configuration
βββ commitlint.config.js # Commitlint configuration
βββ docker-compose.yml # Docker Compose configuration
βββ Dockerfile # Docker configuration
βββ nginx.conf # Nginx configuration
βββ package.json # Dependencies and scripts
βββ playwright.config.ts # Playwright configuration
βββ postcss.config.js # PostCSS configuration
βββ tailwind.config.js # Tailwind configuration
βββ tsconfig.json # TypeScript configuration
βββ vite.config.ts # Vite configuration
βββ vitest.config.ts # Vitest configuration
- Node.js 18.x or higher
- pnpm 8.x or higher (recommended) or npm
- Clone the repository:
git clone <your-repo-url>
cd react-boilerplate- Install dependencies:
pnpm install- Copy environment variables:
cp .env.example .env- Start the development server:
pnpm devThe app will be available at http://localhost:3000
pnpm dev- Start development serverpnpm build- Build for productionpnpm preview- Preview production build
pnpm lint- Run ESLintpnpm lint:fix- Fix ESLint errorspnpm format- Format code with Prettierpnpm format:check- Check code formattingpnpm type-check- Run TypeScript type checking
pnpm test- Run unit testspnpm test:ui- Run tests with UIpnpm test:coverage- Run tests with coveragepnpm test:e2e- Run E2E testspnpm test:e2e:ui- Run E2E tests with UI
pnpm analyze- Analyze bundle size
pnpm buildThe built files will be in the dist/ directory.
docker build -t react-boilerplate .
docker run -p 3000:80 react-boilerplateOr use Docker Compose:
docker-compose up# Run all tests
pnpm test
# Watch mode
pnpm test --watch
# With coverage
pnpm test:coverage
# With UI
pnpm test:ui# Run E2E tests
pnpm test:e2e
# With UI
pnpm test:e2e:ui
# Specific browser
pnpm test:e2e --project=chromiumCustomize your theme in tailwind.config.js and src/index.css. The boilerplate includes:
- Light/dark mode
- Custom color palette
- Design tokens via CSS variables
TypeScript path aliases are configured in tsconfig.json and vite.config.ts:
@/βsrc/@/components/βsrc/components/@/hooks/βsrc/hooks/- etc.
Create a .env file based on .env.example:
VITE_API_BASE_URL=https://api.example.com
VITE_API_TIMEOUT=30000Access in code:
import { apiConfig } from '@/config/env';
console.log(apiConfig.baseURL);- Place reusable UI components in
src/components/ui/ - Place feature-specific components in
src/features/[feature-name]/ - Use meaningful component names
- Use Zustand for client state (UI state, user preferences)
- Use React Query for server state (API data)
- Keep stores small and focused
- Components: PascalCase (e.g.,
UserProfile.tsx) - Hooks: camelCase with 'use' prefix (e.g.,
useAuth.ts) - Utilities: camelCase (e.g.,
formatDate.ts) - Types: PascalCase (e.g.,
User.ts)
This boilerplate enforces:
- Conventional commits (feat:, fix:, docs:, etc.)
- Linting before commit
- Type checking in CI/CD
Example commit:
git commit -m "feat: add user authentication"Change the port in vite.config.ts:
server: {
port: 3001, // Change this
}Run type checking:
pnpm type-checkClear cache and rebuild:
rm -rf node_modules dist .vite
pnpm install
pnpm build- React Documentation
- TypeScript Documentation
- Vite Documentation
- Tailwind CSS Documentation
- TanStack Query Documentation
- Zustand Documentation
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'feat: add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License.
Built with modern tools and best practices from the React ecosystem.
Happy Coding! π