#Abort SSR for entire layout

1 messages · Page 1 of 1 (latest)

green plover
#

I've been dealing with a number of hydration failed issues on a route I have that merges local storage into some data before the first render - meaning the server render will never match the first client render. I'm not really interested in rendering twice (eg once in a 'loading' state); is there a pattern for exempting an entire layout route tree from server side rendering entirely?

hallow nebulaBOT
#

🔎 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)

unique vault
# green plover I've been dealing with a number of hydration failed issues on a route I have tha...

Load all the component tree with dynamic without ssr. anyway i dont see how loading state is related (localstorage is not async) .You need to read it in useEffect to avoid hydration problems. or you can use Zustand store read that data and draw using zustand subscription in your componentes anyway you gonna need double render (you are using a hook to read values after you render the initial UI) unless you lazyload the components (dynamic again) after you read and pass the data via prop. No idea what you storing in localstorage but i prefer store evrything i can in database for persistence across devices.

green plover
#

how do I define that at the layout though when the subtree is just {children}

unique vault
#

Sorry didnt notice your response. you dont since children is passed by router as far i know you cant load children using dynamic you need to load a dynamic component with Dynamic but since you seem to dont want use server components at all what is the point of use app directory. If you want something fully client maybe you should try pages directory. But dont forget you wont have SEO using lazy load. Im having hard time to imagine what you doing exactly and why you need such a strong use of localstorage (i wont even use that for shopping cart) because that kinda data is important to be in server for client suggestion.

green plover
#

It’s an electron app it’s not a typical website

west basalt
#

I've been dealing with a number of hydration failed issues on a route I have that merges local storage into some data before the first render - meaning the server render will never match the first client render.
yep that tracks.

I'm not really interested in rendering twice (eg once in a 'loading' state); is there a pattern for exempting an entire layout route tree from server side rendering entirely?
Instead of storing things in the localStorge, maybe you can trrryyy using the cookies since it will get sent the first time you request your pages to the server.

if ure using an electron app, i dont think its really feasible to not render twice (?) otherwise just make a regular web app...

green plover
#

yeah it's a bit unfortunate, I just use the same nextjs stuff to serve the desktop and web version of the app but the desktop routes have some edge cases that nextjs isn't the best tool for