react-router
Version:
A complete routing library for React.js
67 lines (45 loc) • 1.3 kB
Markdown
API: `Router`
=============
The main export, `Router`, contains several methods that may be used to
navigate around the application.
```js
// cjs modules
var Router = require('react-router')
// or global build
window.ReactRouter
```
Methods
-------
Programatically transition to a new route.
```js
Router.transitionTo('user', {id: 10}, {showAge: true});
Router.transitionTo('about');
Router.transitionTo('/users/10?showAge=true');
```
Programatically replace current route with a new route. Does not add an
entry into the browser history.
```js
Router.replaceWith('user', {id: 10}, {showAge: true});
Router.replaceWith('about');
Router.replaceWith('/users/10?showAge=true');
```
Programatically go back to the last route and remove the most recent
entry from the browser history.
```js
Router.goBack();
```
Creates an `href` to a route. Use this along with `ActiveState` when you
need to build components similar to `Link`.
```js
// given a route like this:
<Route name="user" path="users/:userId"/>
Router.makeHref('user', {userId: 123}); // "users/123"
```