A complete routing library for React
React Router keeps your UI in sync with the URL. It has a simple API with powerful features like lazy code loading, dynamic route matching, and location transition handling built right in. Make the URL your first thought, not an after-thought.
Docs & Help
Note: If you are still using React Router 0.13.x the docs can be found on the 0.13.x branch.
Browser Support
We support all browsers and environments where React runs.
Installation
npm + webpack/browserify
$ npm install react-router
Then with a module bundler or webpack, use as you would anything else:
// using an ES6 transpiler, like babel // not using an ES6 transpilervar ReactRouter = var Router = ReactRouterRoutervar Route = ReactRouterRoutevar Link = ReactRouterLink
You can require only the pieces you need straight from the lib
directory:
There's also a UMD build in the umd
directory:
If you're using globals, you can find the library on window.ReactRouter
.
CDN
If you just want to drop a <script>
tag in your page and be done with it, you can use the UMD/global build hosted on cdnjs.
What's it look like?
const App = Reactconst About = React// etc. const Users = React const User = React // Declarative route configuration (could also load this config lazily// instead, all you really need is a single root route, you don't need to// colocate the entire config).React
See more in the Introduction and Advanced Usage.
Thanks
React Router was initially inspired by Ember's fantastic router. Many thanks to the Ember team.
Also, thanks to BrowserStack for providing the infrastructure that allows us to run our build in real browsers.