This is a TanStack Start React application written in TypeScript, featuring:
- TanStack Start full-stack framework
- TanStack Router with SSR and file-based routing
- TypeScript path aliases via
vite-tsconfig-paths(use@/forsrc/) - Tailwind CSS v4 for utility-first styling
- ESLint for linting and Prettier for formatting
- Vitest + React Testing Library for tests
pnpm dev # Start dev server on port 3000 (Vite HMR)
pnpm build # Production build (SSR + client bundles)
pnpm serve # Preview the production build locallypnpm lint # ESLint
pnpm format # Prettier format
pnpm check # ESLint + Prettierpnpm test # Run Vitest suite
pnpm test -- --watch # TDD watch mode
pnpm test -- --coverage # Coverage for PRs touching core flows`pnpm up -L ` # Update dependencies and update pnpm-lock.yaml- Use
@/components/...for imports - Use
lucide-reactfor icons:import { Icon } from 'lucide-react'
pnpm install # Install dependencies- File-based routes live in
src/routes/using lowercase, dot-delimited filenames (e.g.,about.index.tsx). - Export PascalCase components from route files.
- Root shell:
src/routes/__root.tsxdefines the HTML document viashellComponentand<HeadContent />. - The route tree in
src/routeTree.gen.tsis generated by the TanStack router plugin; do not edit manually. - Router configuration is in
src/router.tsx.
- Route loaders for SSR data (
Route.loader/.useLoaderData()in components). - API endpoints via
Route.server.handlers(GET/POST) that act as REST routes. - Server functions via
createServerFn()for RPC-style operations with access to Node APIs.- You may import Node modules (e.g.,
node:fs) in server contexts; Start will tree-shake for the client. - TanStack Query can be added for client-side caching if needed.
- You may import Node modules (e.g.,
- Tailwind CSS v4 via the Vite plugin; global styles in
src/styles.css. src/lib/utils.tsprovidescn()for class merging (clsx + tailwind-merge).- Prefer
class-variance-authorityfor component variants over manual class concatenation. - Shadcn components are added to
src/components/ui/via the CLI.
project/
├── public/ # Static assets
│ ├── manifest.json # PWA manifest
│ └── robots.txt # Search engine directives
├── src/
│ ├── components/ # Reusable React components
│ ├── lib/ # Shared utilities
│ ├── routes/ # File-based route modules
│ │ ├── __root.tsx # Root shell component
│ │ ├── index.tsx # Home page
│ ├── router.tsx # Router configuration
│ ├── routeTree.gen.ts # Auto-generated; do NOT edit
│ └── styles.css # Global styles (Tailwind directives)
├── README.md # Project readme
├── eslint.config.js # ESLint configuration
├── prettier.config.js # Prettier configuration
├── package.json # Dependencies and scripts
├── pnpm-lock.yaml # Lockfile for pnpm
├── tsconfig.json # TypeScript configuration
└── vite.config.ts # Vite bundler configuration
- Route filenames: lowercase with dots for path segments (e.g
marketing.pricing.tsx→/marketing/pricing). - Optional suffixes clarify modes:
.api-request.tsx,.server-funcs.tsx,.full-ssr.tsx. - Components export functions named after their file, in PascalCase.
- Co-locate component-specific hooks; keep shared utilities in
src/lib. - Use
@/alias for imports fromsrc/.
- Framework: Vitest + React Testing Library.
- File naming:
*.test.tsxor*.test.ts, co-located or undersrc/__tests__/. - Mocking: Use
vi.mock()for modules; avoid mutating globals. - Accessibility: Include a11y assertions where relevant.
- Coverage: Run
pnpm test -- --coveragefor PRs that touch core flows. - Note: If no tests exist yet, create them following the above conventions.
- ESLint for linting and Prettier for code formatting.
- Configuration in
eslint.config.jsandprettier.config.js. pnpm checkruns lint + format together.src/routeTree.gen.tsis excluded from linting checks.
- Server-side file I/O and other Node APIs are valid inside server contexts (API handlers, server functions, or loaders that execute on the server).
- Access loader data with
Route.useLoaderData()inside components for type-safe SSR data. - Devtools:
__root.tsxwires TanStack Devtools and Router DevTools in development. - Place static assets in
public/and reference via root-relative URLs.
- Create
src/routes/path.to.route.tsxusing dot notation. - Export
RouteviacreateFileRoute('/path/to/route'). - Provide a
componentand optionally aloader(SSR),server.handlers(API), or server functions. routeTree.gen.tsis automatically generated on save. Do not edit it manually.- Document complex routes or novel patterns in
docs/.
- Use Conventional Commits (e.g.,
feat:,fix:,chore:,build:,docs:) with optional scope. - Each PR should describe the change, reference issues, and call out config/dependency updates.
- Include screenshots or GIFs for UI-facing work and summarize test runs (e.g.,
pnpm test). - Label UX-visible changes and document new routes in
docs/when applicable.
- Vite + TanStack Start power the environment;
vite.config.tsenablesvite-tsconfig-pathsand Tailwind via the Vite plugin. - Tailwind config files can be added/generated if needed; defaults work via the Vite plugin.
- Update
eslint.config.jsfor project-wide lint adjustments as necessary.
- Tanstack DevTools: Visible in development for inspecting state.
- Router DevTools: Integrated as plugin.
- Prefer
pnpmfor all scripts and package management. - The app supports SSR and SPA usage; pick data-fetching modes accordingly.