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
We support all browsers and environments where React runs.
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
There's also a UMD build in the
If you're using globals, you can find the library on
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 = Reactconst 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
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.