Scaffold React project with Vite
✓Works with OpenClaudeYou are a React developer setting up a new project. The user wants to scaffold a React project using Vite, which provides a modern development environment with fast build times and hot module replacement.
What to check first
- Ensure Node.js 14.18+ is installed:
node --version - Verify npm or yarn is available:
npm --version
Steps
- Run
npm create vite@latest my-react-app -- --template reactto scaffold the project with React template - Navigate into the project directory:
cd my-react-app - Install dependencies using
npm installto add all required packages from package.json - Verify the generated project structure includes
src/,public/,vite.config.js, andindex.html - Start the development server with
npm run devto launch the app on http://localhost:5173 - Open
src/App.jsxand modify the default component to begin building - Test that hot module replacement (HMR) works by saving a change to
src/App.jsx— the browser should refresh automatically - When ready to deploy, run
npm run buildto create an optimized production bundle in thedist/folder
Code
// vite.config.js - default generated config
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
export default defineConfig({
plugins: [react()],
server: {
port: 5173,
open: true // automatically open browser on dev server start
}
})
// src/main.jsx - entry point
import React from 'react'
import ReactDOM from 'react-dom/client'
import App from './App.jsx'
import './index.css'
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
)
// src/App.jsx - sample component
import { useState } from 'react'
import './App.css'
function App() {
const [count, setCount] = useState(0)
return (
<>
<h1>Vite + React</h1>
<button onClick={() => setCount((count) => count + 1)}>
count is {count}
</button>
</>
)
}
export default App
Pitfalls
- Vite uses ES modules natively; CommonJS imports may cause issues — stick to ES6
importstatements - The dev server runs on port 5173 by default, not 3000 like Create React App — check your
http://localhost:5173not the old port index.htmlis the entry point (not hidden in public/), and Vite serves it directly — scripts are linked with<script type="module">in the template- Hot Module Replacement requires proper React Fast Refresh setup via `@
Common Pitfalls
- Treating this skill as a one-shot solution — most workflows need iteration and verification
- Skipping the verification steps — you don't know it worked until you measure
- Applying this skill without understanding the underlying problem — read the related docs first
When NOT to Use This Skill
- When a simpler manual approach would take less than 10 minutes
- On critical production systems without testing in staging first
- When you don't have permission or authorization to make these changes
How to Verify It Worked
- Run the verification steps documented above
- Compare the output against your expected baseline
- Check logs for any warnings or errors — silent failures are the worst kind
Production Considerations
- Test in staging before deploying to production
- Have a rollback plan — every change should be reversible
- Monitor the affected systems for at least 24 hours after the change
Related Scaffolding Skills
Other Claude Code skills in the same category — free to download.
Next.js Starter
Scaffold Next.js project with common setup
Express Starter
Scaffold Express.js project with structure
TypeScript Config
Set up TypeScript configuration
ESLint Config
Configure ESLint with custom rules
Prettier Config
Set up Prettier configuration
Monorepo Setup
Set up monorepo with Turborepo/Nx
Jest Config
Configure Jest testing framework
Vitest Config
Configure Vitest testing framework
Want a Scaffolding skill personalized to YOUR project?
This is a generic skill that works for everyone. Our AI can generate one tailored to your exact tech stack, naming conventions, folder structure, and coding patterns — with 3x more detail.