Back to the page

In the print window, choose “Save as PDF”.

doubtly doubtly.in

How to Create an Vite React App

How to · Updated 16 Mar 2024 · Read online: www.doubtly.in/how-to-create-an-vite-react-app/

How to Create an Vite React App , Vite is a lightning-fast, next-generation build tool that significantly enhances the development experience for React applications. Its unique approach to module bundling and hot module replacement (HMR) leads to near-instant server start and rapid updates during development, making it a compelling choice for modern React projects .

In this guide, we’ll walk you through the process of creating a Vite React app from scratch, covering everything from installation to running your app and exploring key features:

Prerequisites:

Installation and Project Creation:

  1. Open your terminal and navigate to the directory where you want to create your project.
  2. Run the following command:
npm create vite@latest

// after following above command you will get options for name & templates 

or

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

Follow the prompts:

  1. Navigate to the project directory:

    cd my-react-app 
  2. Install dependencies:

    npm install

Running the Development Server:

  1. Start the development server:

    npm run dev

    This will launch the Vite development server, typically at http://localhost:3000. Open your browser and visit this address to see your React app running.

Project Structure:

my-react-app/
├── public/
│   └── index.html
├── src/
│   ├── App.jsx (or App.tsx)
│   ├── index.jsx (or index.tsx)
│   ├── main.jsx (or main.tsx)
│   └── ... (other components and files)
├── vite.config.js (or vite.config.ts)
├── package.json
└── ... (other files)

Key Features of Vite:

Additional Tips:

Practise this on Doubtly (free)