#Make the dev-server also support client side rendering

2 messages · Page 1 of 1 (latest)

mortal garnet
#

Hey, regarding the discussion of Next being the "full" replacement for CRA, I don't think does that fully yet.

While creating a fully static client side app is possible in Next with the dynamic() function, if you want to create a fully static CSA, you have to keep writing that everywhere, or you can do something like this in _app.jsx so all components are client side rendered:

const Comp = dynamic(() => Promise.resolve(Component), { ssr: false });

return <Comp {...pageProps} />

I think a CSA mode will be amazing, it can be enabled when you have output: export set which is already there in next config and you can create a CSA out of the box easily with little friction.

I know Nextjs already exports a CSA on next build with output: export, but in dev server it still server renders all pages by default.

Let me know what you folks think about this.

#

Update: What I meant is you have to explicitly tell next to disable SSR for all components to avoid hydration errors in dev server. With a CSA mode, this can be avoided and ease the DX.