Next.js Discord

Discord Forum

Help in getting code ran after SSR and before CSR

Unanswered
Havana posted this in #help-forum
Open in Discord
HavanaOP
Hello,

I fetch an array in an SSR component and pass it to a CSR component which should compare the array against an array in localStorage ideally before finishing the rendering. i.e useEffect should hopefully not have to be used.

However, if I do a getItem from localStorage in the CSR code it gives an Internal Server Error, localStorage is not defined.

Any advice?

1 Reply

From what I know, you can't do that before finishing the rendering, and you'll have to do it in useEffect only