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.
A modern, responsive streaming platform frontend for customers built with React, TypeScript, and Vite.
- React 19: Modern UI library for building component-based interfaces
- TypeScript: For type safety and better developer experience
- Vite: Fast build tool and development server
- TailwindCSS: Utility-first CSS framework for styling
- Shadcn UI: Accessible and customizable UI components
- React Query: Data fetching, caching, and state management for API calls
- Zustand: Lightweight state management
- i18next: Internationalization framework supporting multiple languages (English and Vietnamese)
- React Router DOM: For client-side routing
- Socket.IO: For real-time communication
- HLS.js: To support HTTP Live Streaming video playback
- MinIO: For object storage integration
- Zod: Schema validation
- React Hook Form: Form handling with validations
- Swiper: For carousel/slider components
- Axios: HTTP client for API requests
src/
├── assets/ # Static assets (images, videos, etc.)
├── components/ # Reusable UI components
│ ├── app/ # Application-specific components
│ │ ├── carosel/ # Carousel components
│ │ ├── categoryCard/ # Category card components
│ │ ├── channelCard/ # Channel card components
│ │ ├── header/ # Header components
│ │ ├── sidebar/ # Sidebar components
│ │ └── streamCard/ # Stream card components
│ ├── base/ # Base components for app structure
│ │ ├── error/ # Error boundary components
│ │ ├── loading/ # Loading indicators
│ │ ├── notification/ # Notification components
│ │ └── theme/ # Theme provider and related components
│ └── ui/ # Shadcn UI components
├── config/ # Configuration files
│ ├── i18Config.ts # i18next configuration
│ ├── minioConfig.ts # MinIO configuration
│ ├── reactQueryConfig.ts # React Query configuration
│ └── socketConfig.ts # Socket.IO configuration
├── constants/ # Application constants
├── guards/ # Authentication and route guards
├── hooks/ # Custom React hooks
│ ├── useAuth.ts # Authentication hook
│ ├── useChannelQuery.ts # Channel data fetching hook
│ ├── useMinio.ts # MinIO hook
│ └── useProducts.ts # Products hook
├── layouts/ # Layout components
│ └── mainLayout.tsx # Main application layout
├── lib/ # Utility functions
├── pages/ # Page components
│ ├── auth/ # Authentication pages
│ ├── chanel/ # Channel pages
│ │ ├── components/ # Channel-specific components
│ │ └── pages/ # Different channel views
│ ├── home/ # Home page
│ ├── video/ # Video playback page
│ └── watching/ # Live streaming page
├── router/ # Routing configuration
├── services/ # API services
│ ├── app/ # Application services
│ ├── auth/ # Authentication services
│ └── base/ # Base API service
├── store/ # State management (Zustand)
│ ├── slices/ # Store slices for different features
│ └── types.ts # Store types
└── types/ # TypeScript type definitions
Contains all reusable components divided into three categories:
- app/: Application-specific components that are used across different pages
- Example:
ChannelCard.tsxrenders channel preview cards on the home page
- Example:
- base/: Core components that handle app structure and behavior
- Example:
ErrorBoundary.tsxcatches and displays errors in components
- Example:
- ui/: Shadcn UI components that provide the base design system
- Example:
button.tsxdefines the button component with various styles
- Example:
Configuration files for various libraries and services:
- i18Config.ts: Sets up internationalization with support for English and Vietnamese
- Example: Defines translation keys like
channel.followersas "followers" in English and "người theo dõi" in Vietnamese
- Example: Defines translation keys like
- reactQueryConfig.ts: Configures React Query for data fetching
Custom React hooks for reusable logic:
- useChannelQuery.ts: Hook for fetching channel data and managing mutations
- Example: Provides functions like
followChannelandunfollowChannelwhile managing loading states
- Example: Provides functions like
All the main pages of the application:
- chanel/: Channel-related pages
- pages/: Different views for a channel (Home, About, Videos, Schedule)
- components/: Channel-specific components like Header
- Example:
Channel.tsxis the parent component that handles data fetching and routing
State management using Zustand:
- slices/: Store slices divided by feature
- Example:
channelSlice.tsmanages channel-related state like following status
- Example:
- types.ts: Type definitions for the store
API services for data fetching:
- app/: Application-specific services
- Example:
channel.tshandles API calls for channel data
- Example:
- auth/: Authentication services
- base/: Base API service with common functionality
The application supports multiple languages with translations managed through i18n:
- English (default)
- Vietnamese
Translation keys are organized by feature (e.g., channel, error, common) and used throughout the application with the useTranslation hook.
React Router DOM is used for client-side routing with routes configured based on features:
- channelRouter.tsx: Manages routes for channel pages (
/channel/:username) - homeRouter.tsx: Configures the home page route
- loginRouter.tsx: Handles authentication routes
The application uses a combination of:
- Zustand: For global app state (authentication, channel data, etc.)
- React Query: For server state management and data fetching
- Clone the repository:
git clone <repository-url>
cd stream-platform-fe-customer- Install dependencies:
pnpm install-
Create
.envfile with necessary configurations (refer to .env.example) -
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
- ⚡️ Fast development and build with Vite
- 🌐 Multilingual support (English and Vietnamese)
- 🎨 Modern UI with Shadcn UI and TailwindCSS
- 📱 Fully responsive design
- 🔌 Real-time communication with Socket.IO
- 📹 Video streaming with HLS.js
- 🔒 Authentication system
- 📦 Efficient state management with Zustand and React Query