A modern, scalable, and production-ready React boilerplate with built-in authentication, state management, and developer tools.
src/
βββ components/ # Reusable UI components
β βββ icons/ # Icon components
β βββ layouts/ # Layout components (AuthLayout, RootLayout)
β βββ shared/ # Shared components across features
β βββ ui/ # Base UI components (Button, Input, Modal, etc.)
βββ features/ # Feature-based modules
β βββ auth/ # Authentication feature
β β βββ components/ # Auth-specific components
β β βββ hooks/ # Auth custom hooks
β β βββ services/ # Auth API services
β β βββ slices/ # Auth state slices
β β βββ types/ # Auth type definitions
β βββ home/ # Home feature module
β βββ products/ # Products feature module
βββ pages/ # Page components
β βββ HomePage.tsx
β βββ LoginPage.tsx
β βββ ProductListPage.tsx
βββ hooks/ # Global custom hooks
βββ context/ # React Context providers
βββ providers/ # App providers (AppProviders, QueryProvider, etc.)
βββ routes/ # Routing configuration
βββ services/ # API services
βββ store/ # Redux store configuration
βββ types/ # Global TypeScript type definitions
βββ utils/ # Utility functions
βββ lib/ # Third-party library configurations
βββ styles/ # Global styles and themes
βββ config/ # App configuration files
βββ mocks/ # Mock data and API handlers
βββ assets/ # Static assets (images, fonts, etc.)
- Frontend Framework: React 19 with TypeScript
- Build Tool: Vite with SWC
- Styling: Tailwind CSS 4
- Routing: React Router
- Package Manager: Bun
- Client State: Redux Toolkit (feature-based slices)
- Server State: React Query (TanStack Query)
- Context API: For auth and theme management
- Language: TypeScript (strict mode)
- Linting: ESLint + Biome (formatting & linting)
- Git Hooks: Husky + lint-staged
- Mocking: MSW (Mock Service Worker)
- Containerization: Docker & Docker Compose
- Environment Management: Dotenv
- JWT-based authentication
- Protected routes with
ProtectedRoute
component - Role-based access control with
AccessControl
- Auth context with
useAuth
hook - Automatic token refresh
- Login/Logout functionality
- Feature-based folder structure
- Modular and scalable design
- Separation of concerns
- Reusable component library
- Custom hooks for business logic
- Hot module replacement (HMR) with Vite
- TypeScript for type safety
- Path aliases configured
- Pre-commit hooks with Husky
- Consistent code formatting with Biome
- Mock API with MSW
- Docker containerization
- Environment variables management
- Optimized build output
- SEO-friendly (robots.txt)
- Asset optimization
- Biome for blazing-fast formatting and linting
- SWC for fast compilation
- Bun for fast package management
- TypeScript strict configuration
- Pre-configured path aliases
- Node.js 18+ (version specified in .nvmrc)
- Bun package manager
- Docker (optional)
-
Clone the repository
git clone https://github.com/mohsen104/boilerplate-react cd react-ts-boilerplate
-
Install dependencies
bun install
-
Set up environment variables
cp .env.example .env
-
Start development server
bun run dev
# Start with Docker Compose
docker-compose up -d
# Stop containers
docker-compose down
# View logs
docker-compose logs -f
bun run dev
- Start development server with HMRbun run preview
- Preview production build locallybun run build
- Build for production (includes TypeScript compilation)bun run lint
- Run Biome linting and auto-fix issuesbun run format
- Format code with Biomebun run check
- Comprehensive Biome check (lint + format)bun run msw:init
- Initialize MSW service worker
- Strict type checking enabled
- Path aliases for clean imports
- Environment variables typing
- API response types with generics
- Custom hooks with proper return types
Each feature is self-contained with:
- Components (UI components)
- Hooks (custom React hooks)
- Services (API calls and business logic)
- Slices (Redux state management)
- Types (TypeScript definitions)
- Protected routes with authentication
- Layout-based routing system
- Lazy loading with React.Suspense
- Route-based code splitting
- TypeScript support with SWC
- Path aliases mapping
- Environment variables exposure
- Asset optimization
- Follow the feature-based architecture
- Use TypeScript for all new code
- Follow Biome formatting rules
- Write meaningful commit messages
- Add proper TypeScript types
- Update documentation when needed
- Use meaningful component and file names
Built with β€οΈ using modern web technologies