With shallow routing you could chnage the URL without running `getInitialProps` of the page. You'll receive the updated "pathname" and the "query" via the `url` prop of the page.
Shallow routig allows you to change the URL without running `getInitialProps`. You'll receive the updated `pathname` and the `query` via the `url` prop of the same page that's loaded, without losing state.
You can do this by invoking the eith `Router.push` or `Router.replace` with `shallow: true` option. Here's an example:
You can do this by invoking the eith `Router.push` or `Router.replace` with `shallow: true` option. Here's an example:
```js
```jsx
// Current URL is "/"
// Current URL is "/"
consthref='/?counter=10'
consthref='/?counter=10'
constas=href
constas=href
Router.push(href,as,{shallow:true})
Router.push(href,as,{shallow:true})
```
```
Now, the URL is updated to "/?counter=10" and page is re-rendered.
Now, the URL is updated to `/?counter=10`. You can see the updated URL with `this.props.url` inside the `Component`.
You can see the updated URL with `this.props.url` inside the Component.
You can also watch for URL changes via [`componentWillReceiveProps`](https://facebook.github.io/react/docs/react-component.html#componentwillreceiveprops) hook as shown below:
You can watch for URL changes via [`componentWillReceiveProps`](https://facebook.github.io/react/docs/react-component.html#componentwillreceiveprops) hook as shown below: