Development Environment Setup
Cat Web uses Vite as its build tool, providing an extremely fast development experience with instant hot module replacement (HMR).Prerequisites
Before starting development, ensure you have:- Node.js (v18 or higher recommended)
- npm (comes with Node.js)
- A code editor (VS Code recommended for TypeScript support)
Environment Variables
Cat Web requires Auth0 configuration and API connection settings. Create a.env file in the project root:
.env
All environment variables must be prefixed with
VITE_ to be exposed to the client-side code. This is a Vite security feature.Starting the Development Server
Start Dev Server
Run the development server:This command starts Vite’s development server, typically on
http://localhost:5173.Hot Module Replacement
Vite provides instant hot reload during development:- React Components: Changes to
.tsxfiles trigger instant updates without losing component state - CSS Changes: Style updates apply immediately without page refresh
- Fast Refresh: Powered by
@vitejs/plugin-react, preserving React state across updates
If you see unexpected behavior, the dev server automatically recovers from most errors. Check the browser console and terminal for any error messages.
ESLint Configuration
Cat Web uses ESLint with TypeScript support to maintain code quality.Running the Linter
- TypeScript errors and type safety issues
- React Hooks rule violations
- React Refresh compatibility issues
- General JavaScript/TypeScript best practices
Current ESLint Setup
The project uses a modern flat config (eslint.config.js) with:
@eslint/js- Core ESLint rulestypescript-eslint- TypeScript-specific lintingeslint-plugin-react-hooks- React Hooks rules enforcementeslint-plugin-react-refresh- Fast Refresh compatibility checks
Enhancing ESLint (Optional)
For production applications, consider enabling type-aware lint rules:eslint.config.js
Project Structure
Understanding the file structure helps when adding new features:Development Workflow
Adding a New Feature
Create Component Files
Add your component in the appropriate directory:
- Shared components →
src/components/ - Page components →
src/pages/ - Utilities →
src/services/orsrc/hooks/
Path Aliases
The project uses@Spa/* as a path alias for cleaner imports:
vite-tsconfig-paths plugin in vite.config.ts.
TypeScript Configuration
Cat Web uses strict TypeScript settings for type safety:- Strict mode enabled: Catches more potential bugs at compile time
- No unused locals/parameters: Enforces clean code
- Target: ES2020: Modern JavaScript features
- Module resolution: bundler: Optimized for Vite
Common Development Tasks
Troubleshooting
Port Already in Use
If port 5173 is occupied, Vite automatically tries the next available port. Check the terminal output for the actual URL.Environment Variables Not Loading
Ensure:- Variables are prefixed with
VITE_ .envfile is in the project root- Dev server was restarted after changing
.env
Hot Reload Not Working
Try:- Save the file again
- Refresh the browser manually
- Restart the dev server
- Check for syntax errors in the terminal
ESLint Errors
Runnpm run lint to see all linting issues. Fix them before committing code.
Next Steps
Building for Production
Learn how to create optimized production builds
Configuration
Configure Auth0 and environment variables
