react-three-offscreen icon indicating copy to clipboard operation
react-three-offscreen copied to clipboard

Not working with nextjs 14+

Open bastiankistner opened this issue 2 years ago • 5 comments

I tried the offscreen canvas with nextjs 14 but it doesn't load the model. Tried it first in my own project and all I see is the fallback. Then checked out this repo and it works fine until I upgrade nextjs to the most recent version. The screen remains blank.

Does anyone happen to know what could be the reason?

bastiankistner avatar Dec 21 '23 11:12 bastiankistner

Hey @bastiankistner, did you ever figure out how to use this with NextJS?

MrUltimate avatar Jan 15 '24 22:01 MrUltimate

This is likely a symptom of Workers being broken in Next 14.1.0 and onwards.

Tracking issue for a fix: https://github.com/vercel/next.js/issues/60920

In the meantime, pin your Next version to 14.0.4 of earlier and it will probably fix the issue. I'm rolling my own solution for Worker + ThreeJS, not react-three-offscreen, so can't verify, but it should be the same thing more or less.

zknicker avatar Jan 26 '24 21:01 zknicker

Anything further on this issue?

It's apparently been fixed in next canary (https://github.com/vercel/next.js/pull/62051), but the issue in R3F/offscreen remains?

Fallback throws; Error: Element type is invalid. Received a promise that resolves to: [object Object]. Lazy element type must resolve to a class or function.

Disabling fallback seems to load the scene and the model, but doesn't render anything to screen.

mofJon avatar Apr 18 '24 10:04 mofJon

I get closer with setting reactStrictMode: false in next.config

ie... displays the scene on screen, but doesn't render materials.

mofJon avatar Apr 18 '24 14:04 mofJon

Any follow up on the issue? In Next 15 it seems to run in dev mode but fails to do so in production.

fatelessdev avatar May 06 '25 08:05 fatelessdev