# Router / History

`@react-sate/store` uses two kind of router history

* createMemoryHistory
* createBrowserHistory

**createMemoryHistory** - is used when SSR is enabled and when running unit tests wth `ReactStateTestBed`&#x20;

**createBrowserHistory** - is used in browser app

In order to do redirects you need to do `history.push` and pass route you want to navigate to. Usually, in React, history is passed via props. However there are cases where you would like to do navigation from place where props are not accessible - like from service *e.g. you would like to redirect user to login page from auth service or from http service if response is 401.*&#x20;

For this reason `@react-state/store` exposes history object. It can be accessed via `RouterHistory` class.

```typescript
import { RouterHistory } from '@react-state/store';
...
RouterHistory.history.push('/login');
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://vytautaspranskunas.gitbook.io/react-state-rxjs/core-concepts/router-history.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
