react-textarea-autosize: [v8] SSR support is broken

It seems, like with introduction of v8 this issue has returned We are using this package with next v11.0.1 and getting the following error, when trying to start our application:

“ReferenceError: document is not defined”

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 11
  • Comments: 17 (6 by maintainers)

Commits related to this issue

Most upvoted comments

I’m running into this problem when using the Next.js Edge Runtime with SSR as well.

I ran into this issue using react-router v7 on Cloudflare Workers. The fix for me was to add worker to ssr.resolve.conditions in my vite.config.ts:

  ssr: {
    target: "webworker",
    noExternal: true,
    resolve: {
      conditions: ["worker", "workerd", "browser"],
    }
  }

This is because react-textarea-autosize has the worker conditional export, but I had to tell Vite to look for that.

Thanks. Unfortunately throws an error while generating the og image on api/og route in next.js:

Uncaught TypeError: (0 , Xo.default) is not a function
    at <unknown> (webpack-internal:///(:3000/api/og/middleware)/./node_modules/satori/dist/index.wasm.cjs:9)
    at eval (webpack-internal:///(:3000/api/og/middleware)/./node_modules/satori/dist/index.wasm.cjs:9:1726)
    at Object.(middleware)/./node_modules/satori/dist/index.wasm.cjs (:3000/api/og/evalmachine.<anonymous>:2352:1)
    at __webpack_require__ (:3000/api/og/evalmachine.<anonymous>:37:33)
    at fn (:3000/api/og/evalmachine.<anonymous>:296:21)
    at eval (webpack-internal:///(:3000/api/og/middleware)/./node_modules/@vercel/og/dist/index.js:5:69)
    at Module.(middleware)/./node_modules/@vercel/og/dist/index.js (:3000/api/og/evalmachine.<anonymous>:2484:1)
    at __webpack_require__ (:3000/api/og/evalmachine.<anonymous>:37:33)
    at fn (:3000/api/og/evalmachine.<anonymous>:296:21)
    at eval (webpack-internal:///(:3000/api/og/middleware)/./pages/api/og.tsx:11:68)
    at Module.(middleware)/./pages/api/og.tsx (:3000/api/og/evalmachine.<anonymous>:869:1)

Probably because satori package is incompatible with the worker condition?

SSR should not reach for react-textarea-autosize.browser.esm.js. This is a browser build - this means that your bundler is configured incorrectly.