Install
$ agentstack add skill-asyrafhussin-agent-skills-react-vite-best-practices ✓ scanned · ✓ verified, works with Claude Code, Cursor, and more.
Security review
✓ PassedNo issues found. Passed automated security review. · v0.1.0 How review works →
- ✓ Prompt-injection patterns
- ✓ Secret / credential exfiltration
- ✓ Dangerous shell & filesystem operations
- ✓ Untrusted network calls
- ✓ Known-malicious package signatures
What it can access
- ✓ Network access No
- ✓ Filesystem access No
- ✓ Shell / process execution No
- ✓ Environment & secrets No
- ✓ Dynamic code execution No
From automated source analysis of v0.1.0. “Used” means the capability is present in the source — more access means more to trust, not that it’s unsafe.
Verified badge
Passed review? Show it. Paste this badge into your README, it links to the public security report.
Reliability & compatibility
Declared compatibility
Compatibility is declared by the source manifest. End-to-end runtime verification is coming, see below.
We're building live execution health for every listing: tool-call success rate, median latency, uptime, and last-checked timestamps, measured, not self-reported. It isn't live yet, so we don't show numbers we can't stand behind.
How agent discovery & health will work →About
React + Vite Best Practices
Comprehensive performance optimization guide for React applications built with Vite. Contains 23 rules across 6 categories for build optimization, code splitting, development performance, asset handling, environment configuration, and bundle analysis.
Metadata
- Version: 2.0.0
- Framework: React + Vite
- Rule Count: 23 rules across 6 categories
- License: MIT
When to Apply
Reference these guidelines when:
- Configuring Vite for React projects
- Implementing code splitting and lazy loading
- Optimizing build output and bundle size
- Setting up development environment and HMR
- Handling images, fonts, SVGs, and static assets
- Managing environment variables across environments
- Analyzing bundle size and dependencies
Rule Categories by Priority
| Priority | Category | Impact | Prefix | |----------|----------|--------|--------| | 1 | Build Optimization | CRITICAL | build- | | 2 | Code Splitting | CRITICAL | split- | | 3 | Development | HIGH | dev- | | 4 | Asset Handling | HIGH | asset- | | 5 | Environment Config | MEDIUM | env- | | 6 | Bundle Analysis | MEDIUM | bundle- |
Quick Reference
1. Build Optimization (CRITICAL)
build-manual-chunks- Configure manual chunks for vendor separationbuild-minification- Minification with OXC (default) or Terserbuild-target-modern- Target modern browsers (baseline-widely-available)build-sourcemaps- Configure sourcemaps per environmentbuild-tree-shaking- Ensure proper tree shaking with ESMbuild-compression- Gzip and Brotli compressionbuild-asset-hashing- Content-based hashing for cache busting
2. Code Splitting (CRITICAL)
split-route-lazy- Route-based splitting with React.lazy()split-suspense-boundaries- Strategic Suspense boundary placementsplit-dynamic-imports- Dynamic import() for heavy componentssplit-component-lazy- Lazy load non-critical componentssplit-prefetch-hints- Prefetch chunks on hover/idle/viewport
3. Development (HIGH)
dev-dependency-prebundling- Configure optimizeDeps for faster startsdev-fast-refresh- React Fast Refresh patternsdev-hmr-config- HMR server configuration
4. Asset Handling (HIGH)
asset-image-optimization- Image optimization and lazy loadingasset-svg-components- SVGs as React components with SVGRasset-fonts- Web font loading strategyasset-public-dir- Public directory vs JavaScript imports
5. Environment Config (MEDIUM)
env-vite-prefix- VITE_ prefix for client variablesenv-modes- Mode-specific environment filesenv-sensitive-data- Never expose secrets in client code
6. Bundle Analysis (MEDIUM)
bundle-visualizer- Analyze bundles with rollup-plugin-visualizer
Essential Configurations
Recommended vite.config.ts
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import path from 'path'
export default defineConfig({
plugins: [react()],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
target: 'baseline-widely-available',
sourcemap: false,
chunkSizeWarningLimit: 500,
rollupOptions: {
output: {
manualChunks: {
vendor: ['react', 'react-dom'],
},
},
},
},
optimizeDeps: {
include: ['react', 'react-dom'],
},
server: {
port: 3000,
hmr: {
overlay: true,
},
},
})
Route-Based Code Splitting
import { lazy, Suspense } from 'react'
const Home = lazy(() => import('./pages/Home'))
const Dashboard = lazy(() => import('./pages/Dashboard'))
const Settings = lazy(() => import('./pages/Settings'))
function App() {
return (
}>
{/* Routes here */}
)
}
Environment Variables
// src/vite-env.d.ts
///
interface ImportMetaEnv {
readonly VITE_API_URL: string
readonly VITE_APP_TITLE: string
}
interface ImportMeta {
readonly env: ImportMetaEnv
}
How to Use
Read individual rule files for detailed explanations and code examples:
rules/build-manual-chunks.md
rules/split-route-lazy.md
rules/env-vite-prefix.md
References
Full Compiled Document
For the complete guide with all rules expanded: AGENTS.md
Source & license
This open-source skill is cataloged on AgentStack and links to its original source — we do not rehost the code.
- Author: AsyrafHussin
- Source: AsyrafHussin/agent-skills
- License: MIT
Install and usage instructions live in the source repository linked above.
Reviews
No reviews yet, be the first.
Write a review
Versions
- v0.1.0 Imported from the upstream source.