A modern, production-ready React + TypeScript frontend template with Vite, featuring a well-organized project structure, comprehensive tooling, and best practices for building scalable applications.
- React 19 - UI library
- TypeScript - Type safety
- Vite 7 - Build tool and dev server
- React Router 7 - Declarative routing
- TanStack Query - Server state management
- Tailwind CSS 4 - Utility-first CSS framework
- shadcn/ui - High-quality component library
- Vitest - Unit testing framework
- Biome + Ultracite - Linting and formatting
- Husky - Git hooks
- β‘ Fast Development - Vite HMR for instant updates
- π¨ Modern UI - shadcn/ui components with Tailwind CSS
- π¦ Type Safety - Full TypeScript support
- π§ͺ Testing Ready - Vitest configured and ready to use
- π― Code Quality - Biome + Ultracite for consistent code style
- π Git Hooks - Husky pre-commit and pre-push hooks
- π± Responsive - Mobile-first design approach
- βΏ Accessible - Built with accessibility in mind
src/
βββ @types/ # TypeScript types (api/, filters/)
βββ api/ # API layer: axios instances, queries, mutations
β βββ [baseURL config] # baseURL configuration
β βββ [feature]/ # e.g. login, users, agents, events, etc.
β βββ queries/ # Feature-specific queries
β βββ mutations/ # Feature-specific mutations
β βββ [feature].ts # Functions using baseURL and creating requests
βββ assets/ # Static assets (favicon, logos)
βββ components/ # Shared UI components
β βββ ui/ # shadcn/ui primitives (Button, Card, Input, etc.)
β βββ Cards/ # StatsProgressCard, StatsSimpleCard, Toplist
β βββ Charts/ # BarChart
β βββ DatePicker/, DateRangeFilter/, Filter/
β βββ Header/, ModeToggle/, Pagination/, Search/
βββ config/ # App configuration (e.g. env)
βββ constants/ # Layout and app constants
βββ contexts/ # React contexts (auth, theme, toast)
βββ hooks/ # Custom React hooks
βββ layout/ # App layouts
βββ lib/ # Utilities and helpers
βββ pages/ # Route-level pages
β βββ Home/ # Dashboard sections
β β βββ Agents/, Events/, Geral/, Groups/, Users/
β β β βββ [Section].tsx # Section page
β β β βββ components/ # Section-specific components only
β β βββ Home.tsx
β βββ Login/
β βββ Login.tsx
βββ providers/ # Context providers
βββ routes/ # Route definitions
βββ tests/ # Vitest test files
β βββ components/ # Component tests
β βββ hooks/ # Hook tests
β βββ utils/ # Utility function tests
β βββ api/ # API layer tests
βββ utils/ # Utility functions
-
Clone the repository
git clone <repository-url> cd frontend-development-template-cursor
-
Install dependencies
npm install # or pnpm install # or bun install
-
Set up environment variables (if needed)
cp .env.example .env # Edit .env with your configuration -
Start the development server
npm run dev # or pnpm dev -
Open your browser Navigate to
http://localhost:5173
| Script | Description |
|---|---|
npm run dev |
Start development server with HMR |
npm run build |
Build for production |
npm run preview |
Preview production build locally |
npm run lint |
Run ESLint |
npm run test |
Run Vitest tests |
npm run check |
Run Ultracite checks |
npm run fix |
Fix issues with Ultracite |
This project uses Vitest for unit testing. Tests are located in src/tests/ organized by category.
# Run tests once
npm run test
# Run tests in watch mode
npm run test -- --watch
# Run tests with coverage
npm run test -- --coverage- Component tests β
src/tests/components/ - Hook tests β
src/tests/hooks/ - Utility tests β
src/tests/utils/ - API tests β
src/tests/api/
import { render, screen } from "@testing-library/react"
import { describe, it, expect } from "vitest"
import { Button } from "@/components/ui/button"
describe("Button", () => {
it("renders with correct text", () => {
render(<Button>Click me</Button>)
expect(screen.getByText("Click me")).toBeInTheDocument()
})
})This project uses Biome with the Ultracite preset for consistent code style.
# Format code
npm run fix
# Check for issues
npm run checkHusky is configured with pre-commit and pre-push hooks to ensure code quality:
- Pre-commit: Runs linting and formatting checks
- Pre-push: Runs tests (if configured)
- Files: Use kebab-case (e.g.,
user-profile.tsx,login-form.tsx) - Components: PascalCase for component names (e.g.,
UserProfile,LoginForm) - Variables/Functions: camelCase (e.g.,
getUserData,handleSubmit)
- Use shadcn/ui components - Never recreate base components with raw HTML/CSS
- Keep components small - Maximum 300 lines; break into smaller components
- Maximum 6 props - Use composition or options objects for more props
- No memoization - Avoid
useMemo,React.memo,useCallbackunless profiling shows a need
- Use TanStack Query - Never use
useEffectfor API calls - API layer - Organize by feature in
src/api/[feature]/ - Queries & Mutations - Separate into
queries/andmutations/directories
- Tailwind CSS - Use utility classes, mobile-first approach
- Responsive breakpoints:
sm:,md:,lg:,xl:,2xl: - Don't modify base components - Only adjust layout/spacing, not colors/borders
- Use semantic HTML (
<button>,<nav>,<main>, etc.) - Add
aria-labelto icon-only buttons - Ensure keyboard navigation works
- Maintain visible focus indicators
The project uses path aliases for cleaner imports:
// Instead of
import { Button } from "../../../components/ui/button"
// Use
import { Button } from "@/components/ui/button"Configured in vite.config.ts and tsconfig.json.
vite.config.ts- Vite configurationtsconfig.json- TypeScript configurationbiome.jsonc- Biome linting/formatting configurationeslint.config.js- ESLint configuration.husky/- Git hooks configuration