https://github.com/ReactTraining/react-router
$ npm install --save react-router
```js
// using an ES6 transpiler, like babel
import { Router, Route, Link } from 'react-router'
https://reacttraining.com/react-router/
```sh
$ npm install react-router-dom@next
# or
$ yarn add react-router-dom@next
import {
BrowserRouter as Router,
StaticRouter, // for server rendering
Route,
Link
// etc.
} from 'react-router-dom';
Your first link is to the master branch, which at this time is v3.
In v4, react-router
exports the core components and functions. react-router-dom
exports DOM-aware components, like <Link>
(which renders an <a>
) and <BrowserRouter>
(which interacts with the browser's window.history
).
react-router-dom
re-exports all of react-router
's exports, so you only need to import from react-router-dom
in your project.
Thanks a lot! 馃槃
So in the future, which is now where RR4 is released, which one shall we use for Web development only? Do we just do "yarn add react-router" will do?
You'll use the bindings for your environment. You will probably want to use react-router-dom for 99.9% of web dev.
@pshrmn, thanks !
Thanks Guys!!! @timdorr
thank u ! @timdorr I have confused before.
This helped alot, thanks!
@pshrmn repurposed your answer into documentation ^^^ I think this issue should be re-opened until the documentation is addressed, obviously lots of people have hit this.
Most helpful comment
Your first link is to the master branch, which at this time is v3.
In v4,
react-router
exports the core components and functions.react-router-dom
exports DOM-aware components, like<Link>
(which renders an<a>
) and<BrowserRouter>
(which interacts with the browser'swindow.history
).react-router-dom
re-exports all ofreact-router
's exports, so you only need to import fromreact-router-dom
in your project.