You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: hub/dev-environment/javascript/react-on-windows.md
+12-24Lines changed: 12 additions & 24 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,54 +10,42 @@ ms.date: 03/01/2024
10
10
11
11
# Install React directly on Windows
12
12
13
-
This guide will walk through installing React directly on Windows using the [create-react-app](https://github.com/facebook/create-react-app) toolchain.
14
13
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.
16
15
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).
18
17
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).
21
19
22
20
## Create your React app
23
21
24
22
To install Create React App:
25
23
26
24
1. Open a terminal(Windows Command Prompt or PowerShell).
27
25
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:
> [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`
44
33
45
34
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.
46
35
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.
51
38
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).
53
40
54
41
## Additional resources
55
42
56
-
- [React docs](https://reactjs.org/)
43
+
- [React docs](https://react.dev)
44
+
- [Vite](https://vitejs.dev/)
57
45
- [Install Next.js](./nextjs-on-wsl.md)
58
46
- [Install Gatsby](./gatsby-on-wsl.md)
59
47
- [Install React Native for Windows](https://microsoft.github.io/react-native-windows/docs/getting-started)
60
48
- [Install NodeJS on Windows](./nodejs-on-windows.md)
61
49
- [Install NodeJS on WSL](./nodejs-on-wsl.md)
62
50
- 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