Prerequisites
Before starting, ensure you have:- Node.js 18+ or Bun runtime installed
- Git for version control
- A code editor (VS Code recommended)
Installation
The dev server runs on port 5173 by default and listens on all network interfaces (
::), allowing access from other devices on your network.Development Workflow
Hot Module Replacement (HMR)
Vite provides blazing-fast HMR powered by React SWC for instant updates:- Changes to React components refresh immediately
- CSS updates apply without full page reload
- State is preserved during updates when possible
- HMR overlay is disabled for a cleaner development experience
Path Aliases
The@ alias points to the src directory for cleaner imports:
vite.config.ts:16-18:
Available npm Scripts
Running Tests with Vitest
Test Configuration
The project uses Vitest with jsdom for unit and component testing. Key configuration fromvitest.config.ts:7-11:
Writing Tests
Tests are located insrc/test/ and follow the pattern *.test.ts or *.spec.tsx:
Test Setup
Thesrc/test/setup.ts:1 file imports @testing-library/jest-dom for enhanced matchers and configures window.matchMedia mock for testing components that use media queries.
Code Linting with ESLint
ESLint Configuration
The project uses the modern flat config format with TypeScript ESLint. Fromeslint.config.js:7-25:
Enabled Plugins
- react-hooks: Enforces Rules of Hooks
- react-refresh: Ensures components are HMR-compatible
- typescript-eslint: TypeScript-specific linting rules
Running the Linter
Troubleshooting
Port Already in Use
If port 5173 is already in use, either kill the process or modify the port in
vite.config.ts:9.Module Resolution Errors
Ensure path aliases are configured in both
vite.config.ts and tsconfig.json. The @ alias must point to ./src.Tests Failing
Check that
@testing-library/jest-dom is imported in src/test/setup.ts:1 and Vitest is using the jsdom environment.Next Steps
Project Structure
Learn about the directory organization and file conventions
Building & Deploying
Build for production and deploy to hosting platforms