utkarshdubey / react-spline

A wrapper to painlessly integrate Spline projects into your React code-space. ☀
https://utkarshdubey.github.io/react-spline/
83 stars 14 forks source link

Support for SSG/SSR? #14

Open Blackglade opened 3 years ago

Blackglade commented 3 years ago

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

utkarshdubey commented 3 years ago

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

adalbertopc commented 3 years ago

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 />

Blackglade commented 3 years ago

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