🌐
Vite
vite.dev › guide
Getting Started | Vite
See create-vite for more details on each supported template: vanilla, vanilla-ts, vue, vue-ts, react, react-ts, react-swc, react-swc-ts, preact, preact-ts, lit, lit-ts, svelte, svelte-ts, solid, solid-ts, qwik, qwik-ts. You can use . for the project name to scaffold in the current directory. To create a project without interactive prompts, you can use the --no-interactive flag.
Config
This may cause issues when importing TypeScript files in a monorepo. If you encounter any issues with this approach, you can specify --configLoader runner to use the module runner instead, which will not create a temporary config and will transform any files on the fly.
Building for Production
With Vite, you can use your index.html for that purpose to get the smooth development experience. When it is time to bundle your library for distribution, use the build.lib config option. Make sure to also externalize any dependencies that you do not want to bundle into your library, e.g. vue or react...
Features
Frameworks with HMR capabilities ... updates without reloading the page or blowing away application state. Vite provides first-party HMR integrations for Vue Single File Components and React Fast Refresh. There are also official integrations for Preact via @prefresh/vite. Note you don't need to manually set these up - when you create an app via ...
Env Variables and Modes
In your app, you can render the title using import.meta.env.VITE_APP_TITLE. In some cases, you may want to run vite build with a different mode to render a different title. You can overwrite the default mode used for a command by passing the --mode option flag.
🌐
W3Schools
w3schools.com › react › react_getstarted.asp
React Getting Started
> npx > create-vite my-react-app --template react | o Scaffolding project in C:\Users\stale\my-react-app...
Discussions

Help Me Refine This Step-by-Step Vite + React Setup & Front-End Data Fetching Guide
I am going to create an expansion guide that goes into * Modularity (best practicing for file structuring, components purposed for fetching Vs. having a fetch in a scope) * Testing (test.js suits -- importing their components, global variables in a test file, describes, tests, and mock .js files (factory functions), and Vitest UI) * Handlers (change and submit) * App.jsx login experiences with routes and route paths More on reddit.com
🌐 r/react
4
5
April 20, 2025
Migrate to Vite from CRA
With CRA not being in favor anymore , teams may want to migrate* to a different solution. I had the pleasure to migrate 3 larger freelance projects last year from CRA to Vite, because it was the perfect drop in replacement (compared to Next). I collected notes along the way, but never put them online. Now I thought this may be a good time. Hope this helps anyone with the process. *Disclaimer: Not saying that this migration is necessary for every project, because CRA works as it is at the moment! Also not saying that Vite is the perfect solution here, it's just the most straightforward. If you want to be more compatible with upcoming React features (e.g. RSC), choose Next instead. More on reddit.com
🌐 r/reactjs
47
156
March 29, 2023
Super easy migration from Create React App to Vite
just wanted to say, i just joined a team that has an app built in CRA, and it's complex enough that moving to remix/next.js might not be possible in the foreseeable future - and just playing around with it I've been able to run the app and the build with vite! (tests and hotreload need some work but it seems like common problems) will be bookmarking this for future reference when we can actually do the migration, but I see you're still actively maintaining it, so definitely appreciate it! More on reddit.com
🌐 r/react
8
8
April 29, 2023
How to migrate a CRA app to Vite?
If I were to do it, I would start by creating a new repo with vite. After that I would start moving one component at a time - adding unit tests/storybook whenever possible. Most of the stuff should work without much change but some dependencies might need a version update- that’s why it’s important to do it in a different repo where you can setup CI/CD to make sure you’re not breaking anything. I’m not sure where your GraphQL server is coming in. Ideally that stuff should remain untouched - the whole idea behind gql is to decouple frontend and backend. More on reddit.com
🌐 r/reactjs
22
1
January 25, 2024
🌐
Haruna Zakaria
harunzywrites.hashnode.dev › how-to-create-a-react-app-using-vite-for-the-first-time
How to Create a React App Using Vite for the First Time
May 1, 2025 - In this guide, we’ll walk through how to create a React app using Vite for the first time. Before you start, make sure you have the following installed on your computer: Node.js and npm: You can download them from nodejs.org ... This second option is just a straight from the first one and it allows you to run everything at a go. After the setup, move into your new project folder using: ... Replace my-react-app with whatever name you gave your project.
🌐
React
react.dev › learn › build-a-react-app-from-scratch
Build a React app from Scratch – React
For a list of recommended frameworks, check out Creating a React App. The first step is to install a build tool like vite, parcel, or rsbuild. These build tools provide features to package and run source code, provide a development server for ...
🌐
Reddit
reddit.com › r/react › help me refine this step-by-step vite + react setup & front-end data fetching guide
r/react on Reddit: Help Me Refine This Step-by-Step Vite + React Setup & Front-End Data Fetching Guide
April 20, 2025 -

Hey all,

I’ve put together a combined guide for settin

g up a React project using Vite, including the necessary Node/npm steps, and a follow-up example for how to fetch and render data in a componentized way (create and show dynamic data; backend code not included).

This started as a rough draft but I’ve restructured it based on some logical flow issues — now Node and npm installation steps come before any React code examples. I’d love feedback from fellow devs to refine it even more, especially in making it beginner-friendly without oversimplifying.

Here’s the full guide:

Part 1: VS Code Steps to Create a New React Project with Vite, and Install npm and Node

Prerequisites

Node.js and npm (or yarn/pnpm):
Ensure Node.js is installed (includes npm). Download from: https://nodejs.org/
Verify in terminal:

node -v 
npm -v  

Optionally install alternatives:

bashCopyEditnpm install --global yarn  
npm install --global pnpm  

VS Code Steps

  1. Open VS Code

  2. Open Terminal: Terminal > New Terminal

  3. Navigate to Your Project FolderbashCopyEdit

cd path/to/your/projects

Run Vite Creation Command

  • npm: npm create vite@latest

  • yarn: yarn create vite

  • pnpm: pnpm create vite

Follow Prompts

  • Project name (e.g., my-vite-app)

  • Framework: React

  • Variant: react (JavaScript) or react-ts (TypeScript)

Navigate into the Project Folder

cd my-vite-app

Install Dependencies

  • npm: npm install

  • yarn: yarn

  • pnpm: pnpm install

Run the Dev Server

  • npm: npm run dev

  • yarn: yarn dev

  • pnpm: pnpm dev

Visit the local server URL that appears in the terminal to view your app.

Part 2: Front-End Data Fetching and Rendering Recap

Goal: Clean separation between fetching logic and rendering logic.

Step-by-Step

  1. Create a data-fetching component (DataFetcher.jsx)

    • This handles calling your API and transforming the data.

  2. Transform backend field names to match frontend expectations before passing as props.

  3. Create a presentational component (FormFields.jsx)

    • This receives props and renders UI.

Fetching Component:

// src/components/DataFetcher.jsx
import React, { useState, useEffect } from 'react';
import FormFields from './FormFields';

function DataFetcher() {
  const [formData, setFormData] = useState({}); // Stores the data used in the form
  const [isSubmitting, setIsSubmitting] = useState(false); // Tracks whether we’re submitting data

  // GET: Called once when the component mounts, pulls data from the backend
  const fetchDataFromAPI = async () => {
    try {
      const response = await fetch('/api/data', {
        method: 'GET', // This is a GET request to retrieve existing data
        headers: { 'Content-Type': 'application/json' } // Tells the backend we're expecting JSON
      });
      if (!response.ok) throw new Error('Failed to fetch'); // If something goes wrong, trigger error
      const data = await response.json(); // Parse response as JSON
      setFormData({
        firstName: data.first_name, // Convert backend field to frontend-friendly name
        lastName: data.last_name // Do the same for any other fields you're using
      });
    } catch (error) {
      console.error('GET error:', error); // Log any error to help with debugging
    }
  };

  // PUT: Called when the form is submitted, sends updated data to the backend
  const updateDataToAPI = async (updatedData) => {
    setIsSubmitting(true); // Set a loading state while submitting
    try {
      const response = await fetch('/api/data', {
        method: 'PUT', // This is a PUT request to update the existing record
        headers: { 'Content-Type': 'application/json' }, // We're sending JSON data
        body: JSON.stringify({
          first_name: updatedData.firstName, // Convert frontend field back to backend name
          last_name: updatedData.lastName // Repeat for each field being sent
        })
      });
      if (!response.ok) throw new Error('Failed to update'); // Throw if the request failed
      const result = await response.json(); // Confirm backend response
      console.log('PUT success:', result); // Log success message
    } catch (error) {
      console.error('PUT error:', error); // Log any error during submission
    } finally {
      setIsSubmitting(false); // Always remove the loading state
    }
  };

  useEffect(() => { fetchDataFromAPI(); }, []); // Runs once when component loads to fetch data

  return <FormFields {...formData} onSubmit={updateDataToAPI} isSubmitting={isSubmitting} />; // Renders the form and passes props
}

export default DataFetcher;

Presenting Component:

// src/components/FormFields.jsx
import React from 'react';

function FormFields({ firstName, lastName }) {
  return (
    <div>
      <p>First Name: {firstName}</p>
      <p>Last Name: {lastName}</p>
      {/* Add more fields here */}
    </div>
  );
}

export default FormFields;

Looking for Feedback:

  • Are the steps logically ordered for someone totally new to Vite + React?

  • Is the division between fetching and rendering clear enough?

  • Any spots where I should elaborate or split things into more digestible sub-steps?

  • Did I miss anything that’s common practice in the community (e.g., folder structure tips, .env usage)?

Thanks in advance for any thoughts or corrections!

🌐
LogRocket
blog.logrocket.com › home › how to build a react + typescript app with vite
How to build a React + TypeScript app with Vite - LogRocket Blog
May 28, 2025 - Delivered once a week, it's your curated guide to the most important conversations around frontend dev, emerging AI tools, and the state of modern software. npm create vite@latest my-react-app -- --template react-ts
🌐
GeeksforGeeks
geeksforgeeks.org › reactjs › how-to-setup-reactjs-with-vite
How to setup ReactJs with Vite ? - GeeksforGeeks
July 31, 2025 - my-react-app is the name of your project. You can change it to any name you prefer. npm create vite@latest my-react-app: This command initializes a new Vite project with a React template.
🌐
DigitalOcean
digitalocean.com › community › tutorials › how-to-set-up-a-react-project-with-vite
How To Set Up a React Project with Vite for Fast Development | DigitalOcean
May 14, 2025 - In this tutorial, you created a new React App using the Vite tool. You scaffolded a fresh React App with the yarn create vite command. After removing the boilerplate code, you created your components by adding a custom image, a CSS file, and changing the title bar.
Find elsewhere
🌐
Medium
medium.com › @miahossain › how-to-create-a-react-app-with-vite-571883b100ef
How To Create a React App with Vite | by Mia Hossain | Medium
February 1, 2024 - This tutorial is for those who want to create a React project using Vite for the very first time. Many ways you can create a react project. In this tutorial, I will show how to create a React project using Vite and npm package manager.
🌐
CodeParrot
codeparrot.ai › blogs › a-beginners-guide-to-using-vite-react
A beginners guide to using Vite with React
Vite provides a straightforward command to set up a new project quickly. Open your terminal and run the following commands: npm create vite@latest my-react-app --template react cd my-react-app npm install
🌐
ThatSoftwareDude.com
thatsoftwaredude.com › content › 14168 › how-to-create-a-react-app-with-vite-step-by-step-guide
How to Create a React App with Vite (Step-by-Step Guide) - ThatSoftwareDude.com
August 13, 2025 - Learn how to quickly set up a React project using Vite with our comprehensive, beginner-friendly step-by-step guide. Discover faster development, simplified configuration, and modern tooling for your next web application.
🌐
Corbado
corbado.com › blog › vite-react
Vite & React: Alternative to Create-React-App
August 23, 2024 - Vite uses Rollup for production builds, combining fast development server performance with optimized output for large-scale applications. Migrating from CRA to Vite requires installing Vite, adding a vite.config.js file with the React plugin and updating package.json scripts to replace CRA commands. In the JavaScript frontend world, there are constantly new tools to build and optimize projects emerging. React, a popular JavaScript library for building user interfaces, has traditionally been paired with Create-React-App (CRA) to simplify setup and development.
🌐
OpenReplay
blog.openreplay.com › vite-create-react-app
Beginner's Guide to Creating a React App Using Vite
December 17, 2024 - Before getting started, ensure ... project. Run the following command to create a new Vite project: npm create vite@latest my-react-app -- --template react...
🌐
OpenReplay
blog.openreplay.com › how-to-build-your-react-app-using-vite
How to Build your React.js App using Vite
December 19, 2022 - Go ahead and change to the newly ... on Vite. To access the dev server, open http://localhost:3000/ on a browser, and you will be served with your first React-Vite application....
🌐
GitHub
github.com › laststance › create-react-app-vite
GitHub - laststance/create-react-app-vite: Create React App Vite ⚛️
Simple CRA style Vite teimpate. Create plain and lightweight React+TS programming environment. And a easy migration base for create-react-app to Vite.
Starred by 161 users
Forked by 31 users
Languages   JavaScript 45.5% | TypeScript 42.2% | CSS 9.5% | HTML 1.4% | Shell 1.4%
🌐
Relia Software
reliasoftware.com › blog › how-to-create-react-app-using-vite
How to Setup and Create Vite React App? Code Sample Included | Relia Software
April 3, 2025 - Start the development server with the command: ... Vite will start a development server, and you'll see a message in your terminal indicating the local URL where your app is running (usually http://localhost:5173).
Call   +84972016100
Address   629 Nguyen Kiem Street, Duc Nhuan Ward, 700000, Ho Chi Minh City
🌐
shadcn/ui
ui.shadcn.com › docs › installation › vite
Vite - shadcn/ui
If you created a monorepo, update apps/web/src/App.tsx and import from @workspace/ui/components/card instead. If you need a new Vite project, create one first and select the React + TypeScript template.
🌐
Alexadam
alexadam.dev › blog › create-react-project-vite
Create a React project from scratch, with TypeScript and Vite
A step by step guide on how to create a React project from scratch, with TypeScript and Vite. You can find the full source code here: https://github.com/alexadam/project-templates/tree/master/projects/react-app-vite
🌐
GitHub
github.com › vitejs › vite › discussions › 14401
create vite@latest React without the example content · vitejs/vite · Discussion #14401
September 17, 2023 - <div> <a href="https://vitejs.dev" target="_blank"> <img src={viteLogo} className="logo" alt="Vite logo" /> </a> <a href="https://react.dev" target="_blank"> <img src={reactLogo} className="logo react" alt="React logo" /> </a> </div> <h1>Vite + React</h1> <div className="card"> <button onClick={() => setCount((count) => count + 1)}> count is {count} </button> <p> Edit <code>src/App.tsx</code> and save to test HMR </p> </div> <p className="read-the-docs"> Click on the Vite and React logos to learn more </p> </> So starting a new vite project is always a chore at the beginning that requires me to immediately: ... Is there a way for me to initialize a new React project with all of that done already? It would be so nice to be able to just do npm create vite@latest and go straight into building my app.
Author   vitejs