Next.js Discord

Discord Forum

Error when building

Unanswered
Maine Coon posted this in #help-forum
Open in Discord
Maine CoonOP
Hello, I have a problem when I'm building my app that I want to staticly build. Added output: "export" and now I have a route: /cases/[id]but my app is fully clientsided, I just fetch data from my api. I think it was a mistake chosing nextjs, or maybe not (not sure if it would be better performance then plain vite), but it's a little more convenient having file based routing and other things.

What can I do?

20 Replies

can you share the error?
my guess is that your api call fails
you check this link too for static routes:
https://nextjs.org/docs/app/guides/static-exports
@Samyar can you share the error? my guess is that your api call fails
Maine CoonOP
Hey, sorry was not online
So basically the problem is that I have "use client"
and I want a /cases/[id] route which still only fetches data on the client
And I don't know how I can have the whole app FULLY clientsided as I said
put the use client in the root layout.
also the thing is that nextjs pre compiles client components on server too
and also still you have not shared the error i can only guess..
@Samyar put the use client in the root layout.
Maine CoonOP
i did, didn't work for some reason
it still asks me to put "use client" in files
@Samyar and also still you have not shared the error i can only guess..
Maine CoonOP
well it's not really an error, but just not allowing me to build, cuz you can't have a route /cases/[id]/page.js and have it staticly built if you don't know the paths or have a function to retrieve data
is there a way to intercept anything /cases/ad in the folder /cases?
Error: Page "/cases/[id]" is missing "generateStaticParams()" so it cannot be used with "output: export" config.
but then if i add that, it errors with can't have "use client" and "generateStaticParams()"
but I don't wanna prebuild the pages because I don't know them in the beginning, so thats why I'm fetching data on the client,, so not sure how to approach
This is pretty much the issue I'm having aswell
damn