แก้ไข

แชร์ผ่าน


Install React directly on Windows

This guide walks through setting up a React development environment directly on Windows using the Vite frontend tooling.

We recommend these instructions if you are new to React or building a project that does not need a Linux environment. If you plan to use Bash tooling extensively or deploy to a Linux server, consider installing React on WSL instead.

For background on React and the different scenarios — web apps, mobile apps (React Native), and native desktop apps (React Native for Desktop) — see the React overview.

Prerequisites

  • Node.js: Required to run Vite and npm. Install using nvm-windows for easy version management.

Create your React app

  1. Open a terminal (Windows Command Prompt or PowerShell).

  2. Create a new project folder and enter it:

    mkdir ReactProjects
    cd ReactProjects
    
  3. Create a new React app using Vite:

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

    Vite will scaffold a new React project in the my-react-app folder.

  4. Navigate into the new app folder and install dependencies:

    cd my-react-app
    npm install
    
  5. Start the local development server:

    npm run dev
    

    Your app will be available at http://localhost:5173. Use Ctrl+C to stop the server.

  6. When you are ready to deploy, build a production bundle:

    npm run build
    

    Output is placed in the dist folder. See Deploying a Static Site for hosting options.

Note

Vite is ideal for single-page apps (SPAs). If you need server-side rendering or a Node.js backend, consider Next.js instead. For static site generation, see Gatsby.

Additional resources