diff --git a/readme.md b/readme.md index c8e00f1204..e5b3870959 100644 --- a/readme.md +++ b/readme.md @@ -720,6 +720,29 @@ export default ({ url }) => ``` +The router instance should be only used inside the client side of your app though. In order to prevent any error regarding this subject, when rendering the Router on the server side, use the imperatively prefetch method in the `componentDidMount()` lifecycle method. + +```jsx +import React from 'react' +import Router from 'next/router' + +export default class MyLink extends React.Component { + componentDidMount() { + Router.prefetch('/dynamic') + } + + render() { + return ( +
+ setTimeout(() => url.pushTo('/dynamic'), 100)}> + A route transition will happen after 100ms + +
+ ) + } +} +``` + ### Custom server and routing