Next.js Discord

Discord Forum

Why some of my pages get error in build time?

Answered
American Shorthair posted this in #help-forum
Open in Discord
American ShorthairOP
Answered by American Shorthair
Hey @B33fb0n3
Thanks for your help!

The issue is now solved. The problem was with @uidotdev/usehooks and not wrapping my component that has useSearchParams() with Suspense.
View full answer

10 Replies

American ShorthairOP
I have been having this kind of issues for two days and was not able to find a solution for it.
I included one of my page (3rd image) that there is nothing inside it, but I get error.
@American Shorthair Click to see attachment
you need to put all your components like queryclient provider, toaster, preventreload, darkbackground, ... first inside your body and if they are clientside (like queryclientprovider, toaster, ...) then excluded them into a "GlobalProvider" component that is a client component and imports all your stuff (see attached)
American ShorthairOP
Thanks @B33fb0n3 for your answer!

Even when importing nothing, I get the same issue in build time.
I am using @uidotdev/usehooks that should be in client only component, is that causing the error?
@American Shorthair I am using @uidotdev/usehooks that should be in client only component, is that causing the error?
I haven't used that library yet, but it can be the issue. However: when you don't import or use it (as you just said) it does not seem to be the issue. Can you provide a repro? Like a github reproduction (only with the code needed to reproduce the error) or maybe even https://codesandbox.io/
American ShorthairOP
Hey @B33fb0n3
Thanks for your help!

The issue is now solved. The problem was with @uidotdev/usehooks and not wrapping my component that has useSearchParams() with Suspense.
Answer
American ShorthairOP
Off topic, is this way good for exporting and have all the hooks in one file?
@American Shorthair Off topic, is this way good for exporting and have all the hooks in one file?
I wouldn't do it this, but you can choose however you like it 🙂