Skip to content

Commit 7fafb9f

Browse files
alexkrolickgaearon
authored andcommitted
Break out Installation into top-level doc section (reactjs#452)
* Break out Installation into top-level doc section * Update navigation (prev/next, nav tree) - Move Installation section to top - Add next/prev to install pages * add links to other install options from try react page * fix markdown link * Clarify that Quick Start and Install are optional "next steps" * Add top-level CDN page This is useful for Codepen and other Unpkg-y setups * Add link to Tutorial from Try React * Update CRA link in tutorial * Make Try React subheader a proper sentence * Add "minimal" * Explain local dev setup is more work than Codepen etc * Fix typos * Add : between headings * add note that CRA is not lightweight * fix typo * Update add-react-to-a-new-app.md * Update add-react-to-a-new-app.md * Remove the Bower note * Update try-react.md * Tweak wording * Use direct link
1 parent 8d596f2 commit 7fafb9f

File tree

8 files changed

+146
-96
lines changed

8 files changed

+146
-96
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
---
2+
id: add-react-to-a-new-app
3+
title: Add React to a New Application
4+
permalink: docs/add-react-to-a-new-app.html
5+
prev: try-react.html
6+
next: add-react-to-an-existing-app.html
7+
---
8+
9+
The easiest way to get started on a new React project is by using a starter kit.
10+
11+
> Note:
12+
>
13+
> Check out the [Try React](/docs/try-react.html) page if you are looking for lightweight environments to experiment with React.
14+
> The options on this page are designed to help bootstrap single-page applications with linting, testing, bundling, production optimizations, and more.
15+
16+
## Create React App
17+
18+
[Create React App](http://github.com/facebookincubator/create-react-app) is the best way to start building a new React single page application. It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production. You’ll need to have Node >= 6 on your machine.
19+
20+
```bash
21+
npm install -g create-react-app
22+
create-react-app my-app
23+
24+
cd my-app
25+
npm start
26+
```
27+
28+
If you have npm 5.2.0+ installed, you may use [npx](https://www.npmjs.com/package/npx) instead.
29+
30+
```bash
31+
npx create-react-app my-app
32+
33+
cd my-app
34+
npm start
35+
```
36+
37+
Create React App doesn't handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. It uses build tools like [Babel](http://babeljs.io/) and [webpack](https://webpack.js.org/) under the hood, but works with zero configuration.
38+
39+
When you're ready to deploy to production, running `npm run build` will create an optimized build of your app in the `build` folder. You can learn more about Create React App [from its README](https://github.com/facebookincubator/create-react-app#create-react-app-) and the [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#table-of-contents).
40+
41+
## Other Starter Kits
42+
43+
See the Community section for a list of [starter kits](/community/starter-kits.html).
44+
45+
## Advanced
46+
47+
If you prefer to configure a project manually, see [Installing React](/docs/add-react-to-an-existing-app.html#installing-react) in the next section.
Lines changed: 6 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,11 @@
11
---
2-
id: installation
3-
title: Installation
4-
permalink: docs/installation.html
5-
redirect_from:
6-
- "download.html"
7-
- "downloads.html"
8-
- "docs/tooling-integration.html"
9-
- "docs/package-management.html"
10-
- "docs/language-tooling.html"
11-
- "docs/environments.html"
12-
next: hello-world.html
2+
id: add-react-to-an-existing-app
3+
title: Add React to an Existing Application
4+
permalink: docs/add-react-to-an-existing-app.html
5+
prev: add-react-to-a-new-app.html
6+
next: cdn-links.html
137
---
148

15-
React is flexible and can be used in a variety of projects. You can create new apps with it, but you can also gradually introduce it into an existing codebase without doing a rewrite.
16-
17-
Here are a couple of ways to get started:
18-
19-
* [Try React](#trying-out-react)
20-
* [Create a New App](#creating-a-new-application)
21-
* [Add React to an Existing App](#adding-react-to-an-existing-application)
22-
23-
## Trying Out React
24-
25-
If you're just interested in playing around with React, you can use CodePen. Try starting from [this Hello World example code](http://codepen.io/gaearon/pen/rrpgNB?editors=0010). You don't need to install anything; you can just modify the code and see if it works.
26-
27-
If you prefer to use your own text editor, you can also [download this HTML file](https://raw.githubusercontent.com/reactjs/reactjs.org/master/static/html/single-file-example.html), edit it, and open it from the local filesystem in your browser. It does a slow runtime code transformation, so don't use it in production.
28-
29-
If you want to use it for a full application, there are two popular ways to get started with React: using Create React App, or adding it to an existing application.
30-
31-
## Creating a New Application
32-
33-
[Create React App](http://github.com/facebookincubator/create-react-app) is the best way to start building a new React single page application. It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production. You’ll need to have Node >= 6 on your machine.
34-
35-
```bash
36-
npm install -g create-react-app
37-
create-react-app my-app
38-
39-
cd my-app
40-
npm start
41-
```
42-
43-
If you have npm 5.2.0+ installed, you may use [npx](https://www.npmjs.com/package/npx) instead.
44-
45-
```bash
46-
npx create-react-app my-app
47-
48-
cd my-app
49-
npm start
50-
```
51-
52-
Create React App doesn't handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. It uses build tools like [Babel](http://babeljs.io/) and [webpack](https://webpack.js.org/) under the hood, but works with zero configuration.
53-
54-
When you're ready to deploy to production, running `npm run build` will create an optimized build of your app in the `build` folder. You can learn more about Create React App [from its README](https://github.com/facebookincubator/create-react-app#create-react-app-) and the [User Guide](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#table-of-contents).
55-
56-
## Adding React to an Existing Application
57-
589
You don't need to rewrite your app to start using React.
5910

6011
We recommend adding React to a small part of your application, such as an individual widget, so you can see if it works well for your use case.
@@ -134,34 +85,4 @@ Learn [how to tell if your website is serving the right version of React](/docs/
13485

13586
### Using a CDN
13687

137-
If you don't want to use npm to manage client packages, the `react` and `react-dom` npm packages also provide single-file distributions in `umd` folders, which are hosted on a CDN:
138-
139-
```html
140-
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
141-
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
142-
```
143-
144-
The versions above are only meant for development, and are not suitable for production. Minified and optimized production versions of React are available at:
145-
146-
```html
147-
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
148-
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
149-
```
150-
151-
To load a specific version of `react` and `react-dom`, replace `16` with the version number.
152-
153-
If you use Bower, React is available via the `react` package.
154-
155-
#### Why the `crossorigin` Attribute?
156-
157-
If you serve React from a CDN, we recommend to keep the [`crossorigin`](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) attribute set:
158-
159-
```html
160-
<script crossorigin src="..."></script>
161-
```
162-
163-
We also recommend to verify that the CDN you are using sets the `Access-Control-Allow-Origin: *` HTTP header:
164-
165-
![Access-Control-Allow-Origin: *](../images/docs/cdn-cors-header.png)
166-
167-
This enables a better [error handling experience](/blog/2017/07/26/error-handling-in-react-16.html) in React 16 and later.
88+
If you don't want to use npm to manage client packages, the `react` and `react-dom` npm packages also provide single-file distributions in `umd` folders. See the [CDN](/docs/cdn-links.html) page for links.

content/docs/cdn-links.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
id: cdn-links
3+
title: CDN Links
4+
permalink: docs/cdn-links.html
5+
prev: add-react-to-an-existing-app.html
6+
next: hello-world.html
7+
---
8+
9+
The UMD builds of React and ReactDOM are available over a CDN.
10+
11+
```html
12+
<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
13+
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
14+
```
15+
16+
The versions above are only meant for development, and are not suitable for production. Minified and optimized production versions of React are available at:
17+
18+
```html
19+
<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
20+
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>
21+
```
22+
23+
To load a specific version of `react` and `react-dom`, replace `16` with the version number.
24+
25+
### Why the `crossorigin` Attribute?
26+
27+
If you serve React from a CDN, we recommend to keep the [`crossorigin`](https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes) attribute set:
28+
29+
```html
30+
<script crossorigin src="..."></script>
31+
```
32+
33+
We also recommend to verify that the CDN you are using sets the `Access-Control-Allow-Origin: *` HTTP header:
34+
35+
![Access-Control-Allow-Origin: *](../images/docs/cdn-cors-header.png)
36+
37+
This enables a better [error handling experience](/blog/2017/07/26/error-handling-in-react-16.html) in React 16 and later.

content/docs/hello-world.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
id: hello-world
33
title: Hello World
44
permalink: docs/hello-world.html
5-
prev: installation.html
5+
prev: cdn-links.html
66
next: introducing-jsx.html
77
redirect_from:
88
- "docs/"
@@ -12,7 +12,7 @@ redirect_from:
1212
- "docs/getting-started-zh-CN.html"
1313
---
1414

15-
The easiest way to get started with React is to use [this Hello World example code on CodePen](codepen://hello-world). You don't need to install anything; you can just open it in another tab and follow along as we go through examples. If you'd rather use a local development environment, check out the [Installation](/docs/installation.html) page.
15+
The easiest way to get started with React is to use [this Hello World example code on CodePen](codepen://hello-world). You don't need to install anything; you can just open it in another tab and follow along as we go through examples. If you'd rather use a local development environment, check out the [Installation](/docs/try-react.html) section.
1616

1717
The smallest React example looks like this:
1818

content/docs/nav.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1+
- title: Installation
2+
items:
3+
- id: try-react
4+
title: Try React
5+
- id: add-react-to-a-new-app
6+
title: Add React to a New App
7+
- id: add-react-to-an-existing-app
8+
title: Add React to an Existing App
9+
- id: cdn-links
10+
title: CDN Links
111
- title: Quick Start
212
items:
3-
- id: installation
4-
title: Installation
513
- id: hello-world
614
title: Hello World
715
- id: introducing-jsx

content/docs/try-react.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
id: try-react
3+
title: Try React
4+
permalink: docs/try-react.html
5+
next: add-react-to-a-new-app.html
6+
redirect_from:
7+
- "docs/installation.html"
8+
- "download.html"
9+
- "downloads.html"
10+
- "docs/tooling-integration.html"
11+
- "docs/package-management.html"
12+
- "docs/language-tooling.html"
13+
- "docs/environments.html"
14+
---
15+
16+
Try React online or set up your local development environment.
17+
18+
## Online
19+
20+
If you're just interested in playing around with React, you can use an online code playground. Try a Hello World template on [CodePen](codepen://hello-world) or [CodeSandbox](https://codesandbox.io/s/new).
21+
22+
## Minimal HTML Template
23+
24+
If you prefer to use your own text editor, you can also [download this HTML file](https://raw.githubusercontent.com/reactjs/reactjs.org/master/static/html/single-file-example.html), edit it, and open it from the local filesystem in your browser. It does a slow runtime code transformation, so don't use it in production.
25+
26+
## Next Steps
27+
28+
### Quick Start
29+
30+
- Head over to the [Quick Start](/docs/hello-world.html) section for a step-by-step introduction to React concepts.
31+
32+
- Try the [Tutorial](/tutorial/tutorial.html) for a hands-on practical example.
33+
34+
### Complete Development Environment
35+
36+
The lightweight solutions above are the best fit if you are new to React or just experimenting.
37+
38+
When you are ready to build your first application with React, check out the install guides below. These setups are designed to get you up and running with a great developer experience and are ready for production. They include linting, testing, and optimizations built-in; however, they require more time and disk space to set up and install.
39+
40+
- [Add React to a New App](/docs/add-react-to-a-new-app.html): Create a new app with a fully-featured starter kit.
41+
- [Add React to an Existing App](/docs/add-react-to-a-new-app.html): Add React to a build system or a larger app.

content/tutorial/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ This is more work, but lets you work from the comfort of your editor.
5353
If you want to do it, here are the steps to follow:
5454

5555
1. Make sure you have a recent version of [Node.js](https://nodejs.org/en/) installed.
56-
2. Follow the [installation instructions](/docs/installation.html#creating-a-new-application) to create a new project.
56+
2. Follow the [installation instructions](/docs/add-react-to-a-new-app.html) to create a new project.
5757

5858
```bash
5959
npm install -g create-react-app

src/components/LayoutFooter/Footer.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,9 @@ const Footer = ({layoutHasSidebar = false}: {layoutHasSidebar: boolean}) => (
6262
<FooterNav layoutHasSidebar={layoutHasSidebar}>
6363
<MetaTitle onDark={true}>Docs</MetaTitle>
6464
{sectionListDocs.map(section => {
65-
// Skip the Installation page for Quick Start
66-
const defaultItem =
67-
section.items[0].id === 'installation'
68-
? section.items[1].id
69-
: section.items[0].id;
65+
const defaultItem = section.items[0];
7066
return (
71-
<FooterLink to={`/docs/${defaultItem}.html`}>
67+
<FooterLink to={`/docs/${defaultItem.id}.html`}>
7268
{section.title}
7369
</FooterLink>
7470
);

0 commit comments

Comments
 (0)