Skip to content

Commit be973a5

Browse files
committed
Update React on windows guide
1 parent f840d3d commit be973a5

File tree

1 file changed

+12
-24
lines changed

1 file changed

+12
-24
lines changed

hub/dev-environment/javascript/react-on-windows.md

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,54 +10,42 @@ ms.date: 03/01/2024
1010

1111
# Install React directly on Windows
1212

13-
This guide will walk through installing React directly on Windows using the [create-react-app](https://github.com/facebook/create-react-app) toolchain.
1413

15-
We recommend following these instructions if you are new to React and just interested in learning. If you are creating a single-page app (SPA) that you would like to use Bash commands or tools with and/or plan to deploy to a Linux server, we recommend that you [install with create-react-app on Windows Subsystem for Linux (WSL)](./react-on-wsl.md).
14+
This guide will walk through installing React on a Linux distribution (ie. Ubuntu) running on the Windows Subsystem for Linux (WSL) using the [vite](https://vitejs.dev/) frontend tooling.
1615

17-
For more general information about React, deciding between React (web apps), React Native (mobile apps), and React Native for Windows (desktop apps), see the [React overview](./react-overview.md).
16+
We recommend following these instructions if you are new to React and just interested in learning. If you are creating a single-page app (SPA) that you would like to use Bash commands or tools with and/or plan to deploy to a Linux server, we recommend that you [install with vite on Windows Subsystem for Linux (WSL)](./react-on-wsl.md).
1817

19-
> [!WARNING]
20-
> If you've previously installed `create-react-app` on your machine, globally or via `npm install -g create-react-app`, it is recommended to uninstall the package using `npm uninstall -g create-react-app` or `yarn global remove create-react-app` to ensure that `npx` always uses the latest version.
18+
For more general information about React, deciding between React (web apps), React Native (mobile apps), and React Native for Windows (desktop apps), see the [React overview](./react-overview.md).
2119

2220
## Create your React app
2321

2422
To install Create React App:
2523

2624
1. Open a terminal(Windows Command Prompt or PowerShell).
2725
2. Create a new project folder: `mkdir ReactProjects` and enter that directory: `cd ReactProjects`.
28-
3. Install create-react-app, a tool that installs all of the dependencies to build and run a full React.js application:
26+
3. Install React using vite :
2927

3028
```powershell
31-
npx create-react-app my-app
29+
npm create vite@latest my-react-app -- --template react
3230
```
3331
34-
>[!NOTE]
35-
> [npx](https://www.npmjs.com/package/npx) is the package runner used by npm to execute packages in place of a global install. It basically creates a temporary install of React so that with each new project you are using the most recent version of React (not whatever version was current when you performed the global install above). Using the NPX package runner to execute a package can also help reduce the pollution of installing lots of packages on your machine.
36-
37-
4. This will first ask for your permission to temporarily install create-react-app and it's associated packages. Once completed, change directories into your new app ("my-app" or whatever you've chosen to call it): `cd my-app`.
38-
39-
5. Start your new React app:
40-
41-
```PowerShell
42-
npm start
43-
```
32+
4. Once installed, change directories into your new app ("my-react-app" or whatever you've chosen to call it): `cd my-react-app`, install the dependencies: `npm install` and then start your local development server: `npm run dev`
4433
4534
This command will start up the Node.js server and launch a new browser window displaying your app. You can use **Ctrl + c** to stop running the React app in your command line.
4635
47-
> [!NOTE]
48-
> Create React App includes a frontend build pipeline using [Babel](https://babeljs.io/) and [webpack](https://webpack.js.org/), but doesn't handle backend logic or databases. If you are seeking to build a server-rendered website with React that uses a Node.js backend, we recommend [installing Next.js](./nextjs-on-wsl.md), rather than this create-react-app installation, which is intended more for single-page apps. You also may want to consider [installing Gatsby](./gatsby-on-wsl.md) if you want to build a static content-oriented website.
49-
50-
6. When you're ready to deploy your web app to production, running `npm run build` will create a build of your app in the "build" folder. You can learn more in the [Create React App User Guide](https://create-react-app.dev/docs/deployment).
36+
> [!NOTE]
37+
> Vite includes a frontend build pipeline using [Babel](https://babeljs.io/), [esbuild](https://esbuild.github.io/) and [Rollup](https://rollupjs.org/), but doesn't handle backend logic or databases. If you are seeking to build a server-rendered website with React that uses a Node.js backend, we recommend [installing Next.js](./nextjs-on-wsl.md), rather than this Vite installation, which is intended more for single-page apps(SPAs). You also may want to consider [installing Gatsby](./gatsby-on-wsl.md) if you want to build a static content-oriented website.
5138
52-
Learn more in the [Create React App repo on GitHub](https://github.com/facebook/create-react-app). You can also find or file issues here if something doesn't work or ask questions in the GitHub Discussions tab of the repo.
39+
6. When you're ready to deploy your web app to production, running `npm run build` to create a build of your app in the "dist" folder. You can learn more in the [Deploying a Static Site](https://vitejs.dev/guide/static-deploy.html).
5340
5441
## Additional resources
5542
56-
- [React docs](https://reactjs.org/)
43+
- [React docs](https://react.dev)
44+
- [Vite](https://vitejs.dev/)
5745
- [Install Next.js](./nextjs-on-wsl.md)
5846
- [Install Gatsby](./gatsby-on-wsl.md)
5947
- [Install React Native for Windows](https://microsoft.github.io/react-native-windows/docs/getting-started)
6048
- [Install NodeJS on Windows](./nodejs-on-windows.md)
6149
- [Install NodeJS on WSL](./nodejs-on-wsl.md)
6250
- Try the tutorial: [Using React in Visual Studio Code](https://code.visualstudio.com/docs/nodejs/reactjs-tutorial)
63-
- Try the [React learning path](/training/paths/react/)
51+
- Try the [React learning path](/training/paths/react/)

0 commit comments

Comments
 (0)