This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
export default tseslint.config({
extends: [
// Remove ...tseslint.configs.recommended and replace with this
...tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
...tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
...tseslint.configs.stylisticTypeChecked
],
languageOptions: {
// other options...
parserOptions: {
project: ["./tsconfig.node.json", "./tsconfig.app.json"],
tsconfigRootDir: import.meta.dirname
}
}
});You can also install eslint-plugin-react-x and eslint-plugin-react-dom for React-specific lint rules:
// eslint.config.js
import reactX from "eslint-plugin-react-x";
import reactDom from "eslint-plugin-react-dom";
export default tseslint.config({
plugins: {
// Add the react-x and react-dom plugins
"react-x": reactX,
"react-dom": reactDom
},
rules: {
// other rules...
// Enable its recommended typescript rules
...reactX.configs["recommended-typescript"].rules,
...reactDom.configs.recommended.rules
}
});"# base-react-v2"
A modern React TypeScript project with best practices and common integrations.
src/
├── components/ # Reusable UI components
│ ├── layout/ # Layout components
│ ├── product/ # Product-related components
│ └── ui/ # Shadcn UI components
├── config/ # Configuration files
│ ├── minio.ts # MinIO configuration
│ ├── socket.ts # Socket.IO configuration
│ └── reactQuery.ts # React Query configuration
├── hooks/ # Custom React hooks
│ ├── useAuth.ts # Authentication hook
│ ├── useMinio.ts # MinIO hook
│ ├── useProducts.ts # Products hook
│ └── useSocket.ts # Socket.IO hook
├── pages/ # Page components
│ ├── auth/ # Authentication pages
│ └── products/ # Product pages
├── services/ # API services
│ ├── auth.ts # Authentication service
│ ├── base.ts # Base API service
│ └── product.ts # Product service
├── store/ # State management
│ ├── types.ts # Store types
│ └── useStore.ts # Zustand store
├── types/ # Global TypeScript types
├── utils/ # Utility functions
├── App.tsx # Root component
└── main.tsx # Entry point
- ⚡️ Vite + React + TypeScript
- 🎨 Shadcn UI + Tailwind CSS
- 🔄 React Query for data fetching
- 🔌 Socket.IO for real-time features
- 📦 MinIO for file storage
- 📱 Responsive design
- 🔒 Authentication with JWT
- 🎯 TypeScript for type safety
- 🐶 Husky for git hooks
- 📝 Commitlint for commit message validation
- Node.js 18+
- pnpm
- Clone the repository:
git clone <repository-url>
cd react-base-ts- Install dependencies:
pnpm install- Create
.envfile:
VITE_API_URL=https://fakestoreapi.com
# MinIO Configuration
VITE_MINIO_ENDPOINT=localhost
VITE_MINIO_PORT=9000
VITE_MINIO_USE_SSL=false
VITE_MINIO_ACCESS_KEY=minioadmin
VITE_MINIO_SECRET_KEY=minioadmin
VITE_MINIO_BUCKET_NAME=products
VITE_MINIO_PUBLIC_URL=http://localhost:9000
# Socket.IO Configuration
VITE_SOCKET_URL=http://localhost:3000- Start development server:
pnpm devpnpm dev- Start development serverpnpm build- Build for productionpnpm preview- Preview production buildpnpm lint- Run ESLintpnpm format- Format code with Prettier
@tanstack/react-query- Data fetching and cachingaxios- HTTP clientminio- Object storagesocket.io-client- Real-time communicationzustand- State managementzod- Schema validation@hookform/resolvers- Form validationreact-hook-form- Form handlingreact-router-dom- Routinglucide-react- Iconstailwindcss- Stylingshadcn-ui- UI componentshusky- Git hooks@commitlint/cli- Commit message linting
This project follows Conventional Commits specification. Commit messages should be formatted as follows:
<type>[optional scope]: <description>
[optional body]
[optional footer(s)]
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the coderefactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing testsbuild: Changes to the build systemci: Changes to CI configuration files and scriptschore: Other changes that don't modify source or test filesrevert: Reverts a previous commit
feat(auth): add login functionality
fix(api): handle network errors
docs(readme): update installation instructions
style(components): format code according to prettier
- Use TypeScript for type safety
- Follow functional programming patterns
- Implement proper error handling
- Use React Query for data fetching
- Implement responsive design
- Follow component composition patterns
- Use proper naming conventions
- Implement proper loading states
- Handle edge cases
- Use proper form validation
- Follow commit conventions
- Fork the repository
- Create your feature branch
- Commit your changes following the commit conventions
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License.