Next.js Discord

Discord Forum

unexpected page refresh

Answered
Great Auk posted this in #help-forum
Open in Discord
Great AukOP
I have a search route, when I enter the page it automatically refreshes, it doesn't make sense.

I have the application online at: https://jounin.live

Just search for something, I'll leave the code below.
Answered by Ray
wrap your page with Suspense
View full answer

23 Replies

Great AukOP
page.tsx
could you check the log
Great AukOP
there are no errors in the logs and this doesn't happen in development mode, only in production
@Ray npm run build && npm run start on locally
Great AukOP
âš  Entire page /search deopted into client-side rendering. https://nextjs.org/docs/messages/deopted-into-client-rendering /search
Answer
but I would turn the page to server component instead
@Ray wrap your page with `Suspense`
Great AukOP
can you help me with anything else? In dev mode my project in nextjs is very slow, because these rsc requests always cost a few seconds of page load. Is this normal?
this is almost making me go back to normal reactjs, it's too slow in all projects
@Great Auk can you help me with anything else? In dev mode my project in nextjs is very slow, because these rsc requests always cost a few seconds of page load. Is this normal?
1. try to use cache from react to dedup the function
2. use data cache for the db query with fetch or unstable_cache
3. split the data request and wrap it with Suspense if the data doesn't appear on the first screen eg. recommendation
@Ray wrap your page with `Suspense`
Great AukOP
didn't work
@Ray but I would turn the page to server component instead
Great AukOP
example?
@Great Auk example?
the page component receives the searchParams props
so you don't need useSearchParams there
isDesktopView can handle with css
turn SearchForm in client component and push the route inside it
or move useView to SearchForm too
if (isDesktopView) return null
Great AukOP
it worked