Replies: 5 comments 3 replies
-
import dynamic from 'next/dynamic';
// Disable SSR, since three.js doesn't play well with it
const Hero = dynamic(() => import('../components/hero'), { ssr: false });
interface HomeProps {}
const Home = () => {
return (
<>
<h1>Test</h1>
<Hero />
<h1>Test</h1>
</>
);
};
export default Home; This code produces following output after being built (notice how the Hero component is completely missing): https://i.imgur.com/rotG9t0.png |
Beta Was this translation helpful? Give feedback.
-
I came across this issue too, what happened was that I was getting an error but it was not being logged anywhere until I logged the whole component using React DevTools: Now the error is a bit clearer: To see what it's about, I'd then go to |
Beta Was this translation helpful? Give feedback.
-
Having the same problem here |
Beta Was this translation helpful? Give feedback.
-
same problem. |
Beta Was this translation helpful? Give feedback.
-
Still have same problem. Setting ssr to false helps, but it's non option |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there,
I'm working on a little project using three.js and react-three-fiber in Next.js. Since three.js has some issues with running in Node environments (where SSG/SSR happens), I want to use dynamic imports for all components that implement stuff with three.js, so that they only run on the client-side.
This is my code:
In development mode everything works as expected, but when building the app and running
next start
, the screen stays blank when I visit the server. I also tried exporting the generated files usingnext export
and then serving these files, but my screen stays blank as well.Here's the full repository: https://github.com/derjp/next-site
Thanks for any help. If you need additional information, just leave a comment.
Beta Was this translation helpful? Give feedback.
All reactions