#Easy way to disable SSR?

1 messages · Page 1 of 1 (latest)

wicked void
#

Can I disable server-side rendering for testing purposes? Ugh this tag is required? I'll pick a random one.

lusty junco
#

One way is to use dynamic from "next/dynamic":

import dynamic from "next/dynamic"

const YourPage = () => {...}

export default dynamic(() => Promise.resolve(YourPage), {
  ssr: false,
})

You can also check if window is defined and render stuff based on it:

const isSSR = () => typeof window === ‘undefined’; 
#

And there's also react-no-ssr package that you can check out.