This repository contains the vite-react-best-practices skill, a comprehensive guide for building production-ready React Single Page Applications (SPAs) with Vite. This skill is designed to be used by AI coding assistants to provide guidance on performance, architecture, and deployment best practices.
The rules target React 19.3, Vite 8.3 (Rolldown + Oxc), React Router 8.5, TanStack Query 5, and React Compiler 1.x. Vite 8 requires Node ^20.19.0 || >=22.12.0.
This skill provides 11 rules organized into the following categories:
- Static Rewrites (
CRITICAL): Mandatory for client-side routing. Nginx, Netlify, Vercel, Firebase, Cloudflare Pages, S3 + CloudFront, GitHub Pages, Azure Static Web Apps. - Caching Strategy (
CRITICAL): Immutable hashed assets, no-cacheindex.html, CDN cache keys,vite:preloadErrorrecovery. - Build Validation (
HIGH): Typecheck, build, and preview before push; minimal CI workflow. - Environment Variables (
HIGH):VITE_prefix, modes, runtime config,ImportMetaEnvtyping.
- Route Splitting (
HIGH): React Router 8 granularroute.lazy, lazy route discovery,React.lazy+Suspense. - Server State (
HIGH): TanStack Query v5queryOptions,useQuery,useSuspenseQuery,staleTime/gcTime. - Memoization (
MEDIUM): WhenuseMemo/useCallbackstill pay off, and what React Compiler replaces. - Image Optimization (
MEDIUM): LCP priority hints,srcSet/sizes, CLS prevention.
- Colocation (
MEDIUM): Feature-based structure with thin route entries. - Anti-Patterns: Import from Dist (
MEDIUM):exportsmaps and ESM/CJS interop. - Troubleshooting (
MEDIUM): Common Vite 8 fixes, HMR, hydration errors, missing styles.
Each rule file in rules/ is self-contained: frontmatter with impact and tags, rationale, an incorrect example, a correct example, and references.
For a complete, compiled version of all rules, see the AGENTS.md file (also available as CLAUDE.md).
You can install this skill for your AI coding assistant using the npx skills add command:
npx skills add claudiocebpaz/vite-react-best-practicesThis command will install the skill for all supported AI agents found on your system, such as Gemini CLI, Claude Code, OpenCode, and others.
Once installed, your AI coding assistant will automatically use this skill when you ask for help with tasks related to Vite and React. For example, you can ask it to:
- "Review my Vite project for performance issues."
- "Help me set up route splitting in my React application."
- "What are the best practices for caching in a Vite SPA?"
This skill is open source and contributions are welcome. If you have suggestions for improvements or new rules, please open an issue or a pull request in the GitHub repository.
See CHANGELOG.md for the release history.
You can find more information about this skill and discover others on skills.sh and SkillsMP.