Vite Setup Vite Project Setup

Last updated: 2026-11-02

Vite Setup Vite Project Setup

Vite is today's mainstream scaffolder for React projects: one command generates a development environment with hot reloading, and both startup and build times are far faster than the old CRA setup. Whether you are learning or shipping a new product, starting from it is the recommended path. The generated project is a plain npm package, so every tool in the ecosystem works out of the box.

GroupCore Concepts
KindTooling
SinceMainstream in the React 18 / Vite 5 era

ℹ️ Info The editor transpiles JSX to JavaScript and renders the real UI in a sandbox; components mount automatically — no manual render call needed.

📝 Syntax

npm create vite@latest my-app -- --template react
cd my-app
npm install
npm run dev   # Starts the dev server on http://localhost:5173

⚙️ Parameters

--template reactSelects the React (JavaScript) template; use react-ts for a TypeScript project.

Returns:No return value — this is a scaffolding tool: what it produces is a local project directory and a set of npm scripts.

▶ Example

The example runs out of the box: it auto-renders when expanded, and edits take effect instantly.

Output:

A monospace card lists four lines of "file name — description"; clicking any line highlights it, and the bottom line shows "Currently selected: xxx", mimicking how you browse the directory of a Vite project and what each file is responsible for.

💡 Key Points

ℹ️ Info create-react-app is no longer maintained and should not be picked for new projects; Vite is the community default today.
💡 Tip npm run dev serves on port 5173 by default; change server.port in vite.config.js to use a different one.
⚠️ Warning Vite requires Node.js 18 or newer — run node -v after installing to confirm.
More case studies coming soon.

📚 Related Tutorials

❓ FAQ

Q Can I still use create-react-app?
A It runs, but it is no longer recommended: the official team no longer maintains it actively, it starts slowly and depends on outdated packages. Use Vite (or a framework such as Next.js) for new projects.
Q How do I create a React project with Vite?
A Run npm create vite@latest my-project -- --template react, cd into the folder, run npm install and then npm run dev.
Q The page will not open after npm run dev — what now?
A Read the error in the terminal first: a busy port means switching ports, missing dependencies mean running npm install, and a Node version below 18 means upgrading.
Web-Tutorial.com

Web-Tutorial Tech Team

A team of developers maintaining programming tutorials. Each tutorial is written and reviewed by developers with expertise in that field. We work to keep our content accurate and reliable — if you spot an issue, please let us know.

100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏