#Error: Page "/[[...slug]]/page" is missing param "/users" in "generateStaticParams()"

7 messages · Page 1 of 1 (latest)

spark bison
#

I am in the process of migrating a Vite client app to Next.js App router, I have followed the guide here: https://nextjs.org/docs/app/building-your-application/upgrading/from-vite
The app uses react-router for client side routing still, which will later be migrated to the Next.js app router incrementally.
I can now successfully run the the dev server and the app works, but whenever I reload on a page other than "/" I get an error saying the page is missing params.
I followed the guide exactly, and used a single catch all route to import my whole client side app, what could I be doing wrong?

Learn how to migrate your existing React application from Vite to Next.js.

vivid craneBOT
#

🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord

🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize

✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)

opal finch
# spark bison I am in the process of migrating a Vite client app to Next.js App router, I have...

you need to add that page to the returned value in generateStaticParams as well.

refer to the generateStaticParams documentation: https://nextjs.org/docs/app/building-your-application/routing/dynamic-routes#generating-static-params

return [
  { slug: [""] }, // for /
  { slug: ["users"] }, // for /users
  { slug: ["hello", "world"] }, // for /hello/world
]

weird, i know, but since you are statically exporting the app and make use of a dynamic route, you have to explicitly declare to nextjs what routes you have. when you fully migrate it should become app/page.tsx, app/users/page.tsx, app/hello/world/page.tsx which make more sense that this.

spark bison
#

I was under the impression from the guide that the catch all would take care of this? I have hundreds of pages and just want a quick way to setup Next so I can incrementally switch over to app router

opal finch
spark bison
#

Oh, well that shouldn't be a problem, I will not be doing static hosting at all, it will be deployed to a Docker image

spark bison
#

That seems to have fixed it, thanks 🙏