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: README.md
+43-81
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Create React apps with no build configuration.
4
4
5
-
*[Getting Started](#getting-started) – How to create a new app.
5
+
*[Creating an App](#creating-an-app) – How to create a new app.
6
6
*[User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md) – How to develop apps bootstrapped with Create React App.
7
7
8
8
Create React App works on macOS, Windows, and Linux.<br>
@@ -11,10 +11,8 @@ If something doesn’t work, please [file an issue](https://github.com/facebooki
11
11
## Quick Overview
12
12
13
13
```sh
14
-
npm install -g create-react-app
15
-
16
-
create-react-app my-app
17
-
cd my-app/
14
+
npx create-react-app my-app
15
+
cd my-app
18
16
npm start
19
17
```
20
18
@@ -30,28 +28,17 @@ They are preconfigured and hidden so that you can focus on the code.
30
28
31
29
Just create a project, and you’re good to go.
32
30
33
-
## Getting Started
31
+
## Creating an App
34
32
35
-
### Installation
33
+
**You’ll need to have Node >= 6 on your local development machine** (but it’s not required on the server). You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
36
34
37
-
Install it once globally:
35
+
To create a new app, run a single command:
38
36
39
37
```sh
40
-
npm install -g create-react-app
38
+
npx create-react-app my-app
41
39
```
42
40
43
-
**You’ll need to have Node >= 6 on your machine**. You can use [nvm](https://github.com/creationix/nvm#installation) (macOS/Linux) or [nvm-windows](https://github.com/coreybutler/nvm-windows#node-version-manager-nvm-for-windows) to easily switch Node versions between different projects.
44
-
45
-
**This tool doesn’t assume a Node backend**. The Node installation is only required for Create React App itself.
46
-
47
-
### Creating an App
48
-
49
-
To create a new app, run:
50
-
51
-
```sh
52
-
create-react-app my-app
53
-
cd my-app
54
-
```
41
+
*([npx](https://medium.com/@maybekatz/introducing-npx-an-npm-package-runner-55f7d4bd282b) comes with npm 5.2+ and higher, see [instructions for older npm versions](https://gist.github.com/gaearon/4064d3c23a77c74a3614c498a8bb1c5f))*
55
42
56
43
It will create a directory called `my-app` inside the current folder.<br>
57
44
Inside that directory, it will generate the initial project structure and install the transitive dependencies:
@@ -77,7 +64,13 @@ my-app
77
64
```
78
65
79
66
No configuration or complicated folder structures, just the files you need to build your app.<br>
80
-
Once the installation is done, you can run some commands inside the project folder:
67
+
Once the installation is done, you can open your project folder:
68
+
69
+
```sh
70
+
cd my-app
71
+
```
72
+
73
+
Inside the newly created project, you can run some built-in commands:
81
74
82
75
### `npm start` or `yarn start`
83
76
@@ -113,6 +106,7 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
113
106
-[Updating to New Releases](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#updating-to-new-releases)
-[Supported Language Features and Polyfills](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#supported-language-features-and-polyfills)
117
111
-[Syntax Highlighting in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#syntax-highlighting-in-the-editor)
118
112
-[Displaying Lint Output in the Editor](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#displaying-lint-output-in-the-editor)
@@ -130,15 +124,19 @@ The [User Guide](https://github.com/facebookincubator/create-react-app/blob/mast
130
124
-[Using Global Variables](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-global-variables)
-[Can I Use Decorators?](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#can-i-use-decorators)
130
+
-[Fetching Data with AJAX Requests](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#fetching-data-with-ajax-requests)
135
131
-[Integrating with an API Backend](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#integrating-with-an-api-backend)
136
132
-[Proxying API Requests in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#proxying-api-requests-in-development)
137
133
-[Using HTTPS in Development](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#using-https-in-development)
138
134
-[Generating Dynamic `<meta>` Tags on the Server](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#generating-dynamic-meta-tags-on-the-server)
139
135
-[Pre-Rendering into Static HTML Files](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#pre-rendering-into-static-html-files)
-[Developing Components in Isolation](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#developing-components-in-isolation)
139
+
-[Publishing Components to npm](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#publishing-components-to-npm)
142
140
-[Making a Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app)
143
141
-[Analyzing the Bundle Size](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#analyzing-the-bundle-size)
@@ -159,57 +157,50 @@ Please refer to the [User Guide](https://github.com/facebookincubator/create-rea
159
157
160
158
***No Lock-In:** You can “eject” to a custom setup at any time. Run a single command, and all the configuration and build dependencies will be moved directly into your project, so you can pick up right where you left off.
161
159
162
-
## Why Use This?
160
+
## What’s Included?
163
161
164
-
**If you’re getting started** with React, use `create-react-app` to automate the build of your app. There is no configuration file, and `react-scripts` is the only extra build dependency in your `package.json`. Your environment will have everything you need to build a modern React app:
162
+
Your environment will have everything you need to build a modern single-page React app:
165
163
166
164
* React, JSX, ES6, and Flow syntax support.
167
165
* Language extras beyond ES6 like the object spread operator.
168
-
* A dev server that lints for common errors.
169
-
* Import CSS and image files directly from JavaScript.
170
166
* Autoprefixed CSS, so you don’t need `-webkit` or other prefixes.
171
-
* A `build` script to bundle JS, CSS, and images for production, with sourcemaps.
167
+
* A fast interactive unit test runner with built-in support for coverage reporting.
168
+
* A live development server that warns about common mistakes.
169
+
* A build script to bundle JS, CSS, and images for production, with hashes and sourcemaps.
172
170
* An offline-first [service worker](https://developers.google.com/web/fundamentals/getting-started/primers/service-workers) and a [web app manifest](https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/), meeting all the [Progressive Web App](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#making-a-progressive-web-app) criteria.
171
+
* Hassle-free updates for the above tools with a single dependency.
173
172
174
-
**The feature set is intentionally limited**. It doesn’t support advanced features such as server rendering or CSS modules. The tool is also **non-configurable** because it is hard to provide a cohesive experience and easy updates across a set of tools when the user can tweak anything.
173
+
Check out [this guide](https://github.com/nitishdayal/cra_closer_look) for an overview of how these tools fit together.
175
174
176
-
**You don’t have to use this.** Historically it has been easy to [gradually adopt](https://www.youtube.com/watch?v=BF58ZJ1ZQxY) React. However many people create new single-page React apps from scratch every day. We’ve heard [loud](https://medium.com/@ericclemmons/javascript-fatigue-48d4011b6fc4) and [clear](https://twitter.com/thomasfuchs/status/708675139253174273) that this process can be error-prone and tedious, especially if this is your first JavaScript build stack. This project is an attempt to figure out a good way to start developing React apps.
175
+
The tradeoff is that **these tools are preconfigured to work in a specific way**. If your project needs more customization, you can ["eject"](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#npm-run-eject)and customize it, but then you will need to maintain this configuration.
177
176
178
-
### Converting to a Custom Setup
177
+
##Popular Alternatives
179
178
180
-
**If you’re a power user** and you aren’t happy with the default configuration, you can “eject” from the tool and use it as a boilerplate generator.
179
+
Create React App is a great fit for:
181
180
182
-
Running `npm run eject` copies all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. Commands like `npm start` and `npm run build` will still work, but they will point to the copied scripts so you can tweak them. At this point, you’re on your own.
181
+
***Learning React** in a comfortable and feature-rich development environment.
182
+
***Starting new single-page React applications.**
183
+
***Creating examples** with React for your libraries and components.
183
184
184
-
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
185
+
Here’s a few common cases where you might want to try something else:
185
186
186
-
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
187
+
* If you want to **try React** without hundreds of transitive build tool dependencies, consider [using a single HTML file or an online sandbox instead](https://reactjs.org/docs/try-react.html).
187
188
188
-
## Limitations
189
+
* If you need to **integrate React code with a server-side template framework** like Rails or Django, or if you’re **not building a single-page app**, consider using [nwb](https://github.com/insin/nwb) or [Neutrino](https://neutrino.js.org/) which are more flexible.
189
190
190
-
Some features are currently **not supported**:
191
+
* If you need to **publish a React component**, [nwb](https://github.com/insin/nwb) can [also do this](https://github.com/insin/nwb#react-components-and-libraries).
191
192
192
-
* Server rendering.
193
-
* Some experimental syntax extensions (e.g. decorators).
194
-
* CSS Modules (see [#2285](https://github.com/facebookincubator/create-react-app/pull/2285)).
195
-
* Importing LESS or Sass directly ([but you still can use them](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-a-css-preprocessor-sass-less-etc)).
196
-
* Hot reloading of components.
193
+
* If you want to do **server rendering** with React and Node.js, check out [Next.js](https://github.com/zeit/next.js/) or [Razzle](https://github.com/jaredpalmer/razzle). Create React App is agnostic of the backend, and just produces static HTML/JS/CSS bundles.
197
194
198
-
Some of them might get added in the future if they are stable, are useful to majority of React apps, don’t conflict with existing tools, and don’t introduce additional configuration.
195
+
* If your website is **mostly static** (for example, a portfolio or a blog), consider using [Gatsby](https://www.gatsbyjs.org/) instead. Unlike Create React App, it pre-renders the website into HTML at the build time.
199
196
200
-
## What’s Inside?
197
+
* If you want to use **TypeScript**, consider using [create-react-app-typescript](https://github.com/wmonk/create-react-app-typescript).
201
198
202
-
The tools used by Create React App are subject to change.
203
-
Currently it is a thin layer on top of many amazing community projects, such as:
199
+
* Finally, if you need **more customization**, check out [Neutrino](https://neutrino.js.org/) and its [React preset](https://neutrino.js.org/packages/react/).
204
200
205
-
*[webpack](https://webpack.js.org/) with [webpack-dev-server](https://github.com/webpack/webpack-dev-server), [html-webpack-plugin](https://github.com/ampedandwired/html-webpack-plugin) and [style-loader](https://github.com/webpack/style-loader)
206
-
*[Babel](http://babeljs.io/) with ES6 and extensions used by Facebook (JSX, [object spread](https://github.com/sebmarkbage/ecmascript-rest-spread/commits/master), [class properties](https://github.com/jeffmo/es-class-public-fields))
0 commit comments