summaryrefslogtreecommitdiffstats
path: root/docs/api/navigation.md
blob: b0a1d2db3051fb340dd054d6bd0890f80b717d57 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# Navigation

### Listen to url change

Listen for changes to the current location:

```js
const onLocationChanged = (location) => {
    console.log(location.pathname);
    console.log(location.query);
    console.log(location.hash);
};

module.exports = GitBook.createPlugin({
    init: (dispatch, getState, { Navigation }) => {
        dispatch(Navigation.listen(onLocationChanged));
    }
});
```

The `onLocationChanged` will be triggered for initial state.

### Changing the url