Facebook Pixel

Setting Up React with Vite

Let's set up a modern React 19 project using Vite. By the end, you will understand how Vite works, why it is preferred over older tools, and how to create a clean project structure ready for development.

1. What Is Vite and Why Use It?

Vite is a fast build tool designed for modern web applications. It provides:

  • Instant development server start
  • Lightning-fast hot module replacement
  • Modern ES module–based tooling
  • Simple configuration

React teams often choose Vite because it gets out of the way and lets React handle the rendering and logic.

2. Installing Vite for a React 19 Project

Make sure Node.js (v18+) is installed. To install Node.js, visit nodejs.org and download the latest LTS version.

Then, run the following commands in your terminal to create a new React project with Vite:

npm create vite@latest my-react-app -- --template react

This generates:

my-react-app/
  index.html
  src/
    App.jsx
    main.jsx
  package.json
  vite.config.js

image

3. Running the Development Server

You can now start the development server by typing following in the terminal:

npm run dev

You will see something like:

VITE v5.x  ready in 300ms
Local: http://localhost:5173/

Open the URL in your browser and your React app should load immediately.

image

4. Understanding the Development Flow

With Vite and React 19:

  • You write React components with modern syntax
  • Vite handles hot reloading efficiently
  • React Compiler optimizes re-renders automatically
  • No manual memoization is required for most cases

This creates a smooth workflow, especially as your project grows.

You now have a fully functioning React project powered by Vite. You learned how to install and configure Vite. This setup forms a strong foundation for building fast and modern applications with the latest React features.

Next, we will explore the folder structure and how to organize your React components effectively.