Next.js Discord

Discord Forum

Set up next.js with react-three-fiber

Answered
Fork-tailed Storm-Petrel posted this in #help-forum
Open in Discord
Fork-tailed Storm-PetrelOP
Can anyone help me setup react-three-fiber in my next.js project. I've searched everywhere but haven't been able to figure it out.
I'm using next.js 15 (App Router).
Answered by Californian
https://github.com/pmndrs/react-three-fiber
Top of the readme says this:
Warning

R3F v8 is not compatible with React 19 or Next 15, which uses React 19. Use the R3F v9 RC instead which can be installed with @react-three/fiber@rc.
View full answer

9 Replies

@Fork-tailed Storm-Petrel Can anyone help me setup react-three-fiber in my next.js project. I've searched everywhere but haven't been able to figure it out. I'm using next.js 15 (App Router).
you can create a client component and then use everything inside there. And inside there you can use the same code as shown here: https://r3f.docs.pmnd.rs/getting-started/introduction#what-does-it-look-like?

The only thing that you need to change is that you put your jsx code inside your return function instead of the .render(...) function
@B33fb0n3 you can create a client component and then use everything inside there. And inside there you can use the same code as shown here: https://r3f.docs.pmnd.rs/getting-started/introduction#what-does-it-look-like? The only thing that you need to change is that you put your jsx code inside your return function instead of the .render(...) function
Fork-tailed Storm-PetrelOP
I am running into issues
like for the mesh element there i get an error saying Property 'mesh' does not exist on type 'JSX.IntrinsicElements'.ts(2339)
and i am getting the same thing for each element
why isn't it recognizing mesh and every other things as native JSX elements.
I guess i need to do some configurations but i don't know what to do
can you share the code (maybe you can even share your github project)? And also screenshots of the error? This is a working reproduction. Can you check against this: https://codesandbox.io/p/sandbox/j8f3m7?file=%2Findex.jsx
Fork-tailed Storm-PetrelOP
I guess there's some version mismatch
is r3f not optimized for react and react dom version 19
Californian
https://github.com/pmndrs/react-three-fiber
Top of the readme says this:
Warning

R3F v8 is not compatible with React 19 or Next 15, which uses React 19. Use the R3F v9 RC instead which can be installed with @react-three/fiber@rc.
Answer
@B33fb0n3 yea, can you downgrade to react 18? or install @react-three/fiber@rc directly. You can see one example of this here: https://github.com/verekia/three-gpu-ecosystem-tests/tree/main/next15-app-r3f9-react19-rsc
Also can you import the whole component that uses threejs while skipping ssr like this:
const ComponentC = dynamic(() => import('../components/C'), { ssr: false })