Reputation: 578
I'm converting a React app to Next.js witch i'm new to. I face a problem of getting page numbers for pagination. In my react app i use this.props.match.params.page
to get the page number, is there a way of using something similar in Next?
Thank you.
Upvotes: 1
Views: 1845
Reputation: 6613
You can access the query params on a client-side with useRouter
hook.
import { useRouter } from 'next/router'
export default () => {
const router = useRouter()
console.log(router.query)
return <div></div>
}
Upvotes: 1