A production-ready React TypeScript template with best practices for modern web development.
- TypeScript - Type-safe code
- React - Functional components with hooks
- Vite - Fast development and optimized builds
- TailwindCSS - Utility-first styling
- Shadcn/ui - Accessible UI components
- React Router - Client-side routing
- TanStack Query - Data fetching and caching
- React Hook Form - Form handling with validation
- Zod - Schema validation
- Zustand - Lightweight state management
- Vitest - Unit testing
- Code Splitting - Lazy loading for optimal performance
src/
├── components/ # Reusable UI components
│ ├── ui/ # Shadcn/ui components
│ └── layout/ # Layout components
├── context/ # React context providers
├── hooks/ # Custom React hooks
├── lib/ # Utility functions
├── pages/ # Page components
├── services/ # API services
├── store/ # Zustand stores
└── types/ # TypeScript type definitions
- Node.js 16+
- Yarn or npm
# Clone the repository
git clone https://github.com/smz-exe/typescript-modern-web-boilerplate.git
cd typescript-modern-web-boilerplate
# Install dependencies
yarn install# Start development server
yarn dev# Build for production
yarn build
# Preview production build
yarn preview# Run tests
yarn test
# Run tests with coverage
yarn test:coverageThe template includes a basic authentication system with:
- Login page with form validation
- JWT-based authentication (mock implementation)
- Protected routes
- User state management with Zustand
Shadcn/ui components included:
- Button (with variants)
- Dialog
- Tooltip
- Tabs
- And more...
- Form validation with Zod schemas
- React Hook Form integration
- Error handling and feedback
- TanStack Query for data fetching and caching
- Type-safe API services
- Loading and error states
- Code splitting with lazy loading
- Optimized bundle size with manual chunks
- Image optimization with vite-imagetools
This template follows these best practices:
- Component Structure - Small, focused components with clear responsibilities
- Type Safety - Comprehensive TypeScript types for all components and functions
- Accessibility - ARIA attributes and keyboard navigation
- Performance - Code splitting, lazy loading, and optimized builds
- Testing - Unit tests for components and utilities
- State Management - Local state with hooks, global state with Zustand
- Code Quality - ESLint and Prettier for consistent code style
- Create a new file in
src/pages/ - Add the route to
App.tsx - Add a link in the navigation component
- Create a new file in
src/components/ - Export the component
- Import and use it in your pages
- Add new methods to the API service in
src/services/ - Create custom hooks in
src/hooks/to use the API
- React Documentation
- TypeScript Documentation
- Vite Documentation
- TailwindCSS Documentation
- TanStack Query Documentation
- React Hook Form Documentation
- Zod Documentation
- Zustand Documentation
This project is licensed under the MIT License - see the LICENSE file for details.