Next.js Discord

Discord Forum

next.js SSG with dynamic routing

Unanswered
Common carp posted this in #help-forum
Open in Discord
Common carpOP
I have a file like this app/[id]/page.tsx , The purpose is that when the user enters the ID, my page can be dynamically configured.

its work when i run npm run dev , but if i run npm run build for the static file , the page is return 404.

how can i use nextjs SSG with dynamic routing ?

3 Replies

Common carpOP
i check the document , it suggest me to use like :
export function generateStaticParams() {
  return [{ id: "1" }, { id: "2" }, { id: "3" }];
}


but where can i get those id , my orignal design is for app/[id]/page.tsx , need to base on the id to configure my webpage?

and evan i setup the above generateStaticParams() , i serve the export out , input localhost:3000/3 <--- it also return 404