NextJS Best Practices / Learn
Unanswered
XandoR posted this in #help-forum
XandoROP
Hello there ! 👋
I'm still learning NextJS and I was wondering if you guys have any advice / good practices I should absolutely use ?
I have a few questions on my own :
- is this a good thing to split code to avoid using "use client" / extract client code inside separated components to keep using SSR as much as possible ?
- I just saw while building my app that I need to wrap my useSearchParams call inside of a Suspense component, is that really important ?
I'm still learning NextJS and I was wondering if you guys have any advice / good practices I should absolutely use ?
I have a few questions on my own :
- is this a good thing to split code to avoid using "use client" / extract client code inside separated components to keep using SSR as much as possible ?
- I just saw while building my app that I need to wrap my useSearchParams call inside of a Suspense component, is that really important ?
1 Reply
Toyger
is this a good thing to split code to avoid using "use client" / extract client code inside separated components to keep using SSR as much as possible ?you don't need to avoid "use client", they still will be prerendered on server, just became interactive on client.
you need to use SSR whenever you needed, and it's anyway basically invoked by default, main reasons to use SSR is SEO/access control/faster page content load for user.
I just saw while building my app that I need to wrap my useSearchParams call inside of a Suspense component, is that really important ?not necessary, but as mentioned in docs https://nextjs.org/docs/app/api-reference/functions/use-search-params#static-rendering it will allow to pre-render static content outside of suspense, instead generating page only on client side render.