0

I see a couple of answers here on error ReferenceError: document is not defined but none of the solutions work for my particular case. Previously marked as duplicate but isn't the solution and the post is 3 years 9 months out of date and the syntax is much different now for both React and Next and SSR vs Client Rendering.

In the terminal it reads:

- error node_modules/styletron-engine-atomic/dist-node-cjs/client/client.js (167:0) @ new StyletronClient
- error ReferenceError: document is not defined
    at eval (./src/app/layout.js:15:16)
    at (sc_client)/./src/app/layout.js (/Users/anthonyweston/Sites/fogg/.next/server/app/page.js:2296:1)
    at __webpack_require__ (/Users/me/Sites/nextjs-baseweb/.next/server/webpack-runtime.js:33:42)
null

I see some references to next/dynamic mentioned in other questions, but that doesn't seem to be the solution here?

The package is available on GitHub if you want to reproduce.

Anthony
  • 317
  • 1
  • 5
  • 23
  • Review if the styletron lib works in the server. – jgatjens May 09 '23 at 19:53
  • I don't understand, sorry. How might I do that? I am using `"use client"` on each of the pages and components, but I still get the `ReferenceError` – Anthony May 14 '23 at 14:28

0 Answers0