Last active
June 10, 2020 02:20
-
-
Save HaNdTriX/b66e30851c2bc3fbc4ee48b4473e2321 to your computer and use it in GitHub Desktop.
Next.js useRouter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 🤫The following code is experimental and might break in the future! | |
// Don't use it if you are using some kind of side-effect patterns like: Helmet, GraphQL or react-side-effect. | |
import { useRouter } from 'next/router' | |
function Home() { | |
const { | |
// `String` of the actual path (including the query) shows in the browser | |
asPath, | |
// `String` Current route | |
route | |
// `Function` navigate back | |
back, | |
// `Function` prefetch a specific page | |
prefetch, | |
// `Function` navigate to a specific page (adds entry to history) | |
push, | |
// `Function` navigate to a specific page | |
replace, | |
// `Object` current query | |
query, | |
// `Function` Reload current page | |
reload | |
} = useRouter() | |
return <div>...</div>; | |
} | |
export default Home; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thank you!