Skip to content

Commit 54829f8

Browse files
committed
add installation information
1 parent e8135e8 commit 54829f8

File tree

2 files changed

+83
-6
lines changed

2 files changed

+83
-6
lines changed
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Installation {id=installation}
2+
3+
React Router runs in multiple environments: browsers, servers, native, and even VR (works in the dev preview!) While many components are shared (like `Route`) others are specific to environment (like `NativeRouter`). Rather than requiring you install two packages, you only have to install the package for the target environment. Any shared components between the environments are re-exported from the environment specific package.
4+
5+
## Web {id=installationweb}
6+
7+
```bash
8+
npm install react-router-dom@next`
9+
# or
10+
yarn add react-router-dom@next
11+
```
12+
13+
All of the package modules can be imported from the top:
14+
15+
```js
16+
import {
17+
BrowserRouter as Router
18+
StaticRouter // for server rendering
19+
Route,
20+
Link
21+
// etc.
22+
} from 'reat-router-dom'
23+
```
24+
25+
If you're going for a really minimal bundle sizes on the web you can import modules directly. Theoretically a tree-shaking bundler like Webpack makes this unnecessary but we haven't tested it yet. We welcome you to!
26+
27+
```js
28+
import Router from 'react-router-dom/BrowserRouter'
29+
import Route from 'react-router/Router'
30+
// etc.
31+
```
32+
33+
## Native {id=installation.native}
34+
35+
We're still working on great documentation for the native capabilities of React Router. For now we recommend you [read the source](https://github.com/ReactTraining/react-router/tree/v4/packages/react-router-native).
36+
37+
```bash
38+
yarn add react-router-native@next
39+
# or if not using the react-native cli
40+
npm install react-router-native@next
41+
```
42+
43+
All of the package modules can be imported from the top:
44+
45+
```js
46+
import {
47+
NativeRouter as Router
48+
DeepLinking,
49+
AndroidBackButton,
50+
Link,
51+
Route
52+
// etc.
53+
} from 'react-router-native'
54+
```
55+
56+
## Who-knows-where {id=installation.who-knows-where}
57+
58+
```bash
59+
yarn add react-router@next
60+
# or if not using the react-native cli
61+
npm install react-router@next
62+
```
63+
64+
All of the package modules can be imported from the top:
65+
66+
```js
67+
import {
68+
MemoryRouter as Router,
69+
Route
70+
// etc.
71+
} from 'reat-router'
72+
```
73+
74+
You can use React Router's navigation anywhere you run React, the navigation state is kept in a memory router. You can look at the implementation of NativeRouter to get an idea on how to integrate.

packages/react-router-website/modules/components/APIDocs.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,24 @@ import MarkdownViewer from './MarkdownViewer'
66
import ScrollToMe from './ScrollToMe'
77

88
export const API = [
9+
{ name: 'Installation',
10+
html: require('../api/Installation.md')
11+
},
912
{ name: 'BrowserRouter',
1013
html: require('../api/BrowserRouter.md')
1114
},
12-
{ name: 'HashRouter',
13-
html: require('../api/HashRouter.md')
14-
},
15-
{ name: 'MemoryRouter',
16-
html: require('../api/MemoryRouter.md')
17-
},
1815
{ name: 'NativeRouter',
1916
html: require('../api/NativeRouter.md')
2017
},
2118
{ name: 'StaticRouter',
2219
html: require('../api/StaticRouter.md')
2320
},
21+
{ name: 'HashRouter',
22+
html: require('../api/HashRouter.md')
23+
},
24+
{ name: 'MemoryRouter',
25+
html: require('../api/MemoryRouter.md')
26+
},
2427
{ name: 'Router',
2528
html: require('../api/Router.md')
2629
},

0 commit comments

Comments
 (0)