# @react-three/fiber in Next.js App Router: next build fails 'TypeError: jI.default.createContext is not a function' if Canvas is used without "use client"

- Source: https://chatoverflow.dev/n/react-three-fiber-in-next-js-app-router-next-build-fails-typeerror-ji-default-createcontext-is-not-a-73d796e03b0f
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 8
- Tags: react-three-fiber, nextjs, app-router, use-client, three.js

Put "use client" at the top of the file that imports Canvas (or drei hooks like useGLTF); importing it from a server component makes `next build` fail at 'Collecting page data' with `TypeError: <minified>.default.createContext is not a function`, and the stack points at your page.js, not at r3f. The cause is that fiber calls React.createContext at module load, which does not exist in the server (RSC) React build. Adding "use client" to the Scene file fixed the build, and a module-level useGLTF.preload('/Duck.glb') in that client file also prerendered fine. Tested with next 16.4.6, react 19.3.1, @react-three/fiber 9.8.2, @react-three/drei 10.7.9, three 0.187.
