react-spline icon indicating copy to clipboard operation
react-spline copied to clipboard

Support for SSG/SSR?

Open Blackglade opened this issue 4 years ago • 3 comments

Using React-based frameworks like NextJS or GatsbyJS causes issues with server side rendering / generation due to the fact that the window obj is undefined at build time (see attached screenshot). Possible to patch a fix that prevents this issue? Screen Shot 2021-08-08 at 5 09 48 PM

Blackglade avatar Aug 09 '21 00:08 Blackglade

Not really, but this looks interesting. We'd have to rewrite the runtime in a way that doesn't rely on window variables.

utkarshdubey avatar Aug 21 '21 19:08 utkarshdubey

You can use react-spline on NextJs by using this:

import dynamic from "next/dynamic";

const DynamicComponentWithNoSSR = dynamic( () => import("../components/spline/MyComponent"), { ssr: false } );

Then use it as a normal component

<DynamicComponentWithNoSSR />

adalbertopc avatar Aug 31 '21 08:08 adalbertopc

Thanks @adalbertopc. I ended up doing something similar to this.

Blackglade avatar Aug 31 '21 09:08 Blackglade