Things to do
Normally, in order to get the id 1 in Next.js dynamic routing (post/1), you can write the following to get the value.
const { id } = router.query;
How do I get this in getServerSideProps?
export async function getServerSideProps(context) {
You can do the following to get it.
export async function getServerSideProps(context) {
const { id } = context.query;
Reference.
Dynamic routing with getServerSideProps in Nextjs
How to get the id of dynamic routing with getServerSideProps in Nextjs
Top comments (0)