3 ms·
Most of these new client side state management libraries are incompatible with any form of SSR. If you see the documentation for Jotai/Zustand/Valtio, the solut
by melony 4y ago
Most of these new client side state management libraries are incompatible with any form of SSR. If you see the documentation for Jotai/Zustand/Valtio, the solution is to avoid using with Next.js at all, or fall back to hacks using context+provider at which point the state manager becomes effectively redundant.
- rebelos 4y agoIsn’t SSR only really relevant when you need to optimize for SEO (which only applies to a subset of apps)? Seems like it doesn’t confer any other significant benefit.
- azemetre 4y agoThink about how the benefits to SEO (page speed, web vitals, less client work) can improve overall app performance. SSR is just one technique.
- purplerabbit 4y agoI'm sorry people are downvoting, because you are correct. SSR (by which I mean Next.js) is the most over-invested in JS tech of all time. It introduces a bunch of crummy DX which never pays for itself from a business standpoint. SSR is only potentially useful for landing pages. In which case you should be using Wordpress or something like Wordpress so you aren't wasting dev resources on something a marketing team should be doing. (If your argument is that SSR is necessary for speed, I'm pretty sure exporting your Wordpress site to static HTML + CSS and using Cloudflare could more than make up for the difference.) The one asterisk I'll add to this is that SSR in the form of the Remix framework may justify its own existence as it removes the need for an explicit API layer, which lets you skip a ton of boilerplate code. This is a big win. The fact that Remix uses SSR is just an implementation detail -- it's the DX that's actually valuable (although SSR fetishists will probably still like it, too.)
- melony 4y agoAnd how exactly do you plan to avoid the flash of white without SSar?
- purplerabbit 4y agoI don’t. Because it’s not worth the hassle, as explained in my comment. If I did want to avoid it I could send html for a generic loading state in my base html template, which does not require ssr. If you’re using Wordpress or static site generators for your public facing pages you won’t have the flash, and if your user is invested enough to have made it past the landing page the flash will be a non issue anywhere else.
- chrisco255 4y agoI use Zustand with Next.js. What is the issue? There are even officially maintained examples by Next: https://github.com/vercel/next.js/tree/canary/examples/with-zustand https://github.com/vercel/next.js/tree/canary/examples/with-... And Jotai: https://github.com/vercel/next.js/tree/canary/examples/with-jotai https://github.com/vercel/next.js/tree/canary/examples/with-...
- BigJono 4y agoGood. Hybrid SSR for everything is the most overengineered bullshit fad I've seen in front end development. The sooner noobs stop cargo culting Next JS the better.