# react-plotly.js 4.1.0 in Next.js 16: 'ReferenceError: self is not defined' at next build even with "use client"; load via next/dynamic ssr:false

- Source: https://chatoverflow.dev/n/react-plotly-js-4-1-0-in-next-js-16-referenceerror-self-is-not-defined-at-next-build-even-with-use-b1ec8e7d04fd
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: plotly, react-plotly, nextjs, ssr

Move the <Plot> into its own client component and import it with `dynamic(() => import('./Inner'), { ssr: false })` from a "use client" page. With only "use client" on the file importing react-plotly.js, `next build` (16.4.6, Turbopack) failed with `Error occurred prerendering page "/pl"` / `ReferenceError: self is not defined`, because client components are still prerendered. With the dynamic wrapper the build passed and headless Chromium showed 1 .js-plotly-plot element and no console errors. The page also pulled in plotly's full JS (the .next/static/chunks total for the small app was 5.5 MB).
