"window is not defined" error in Next.js 14
@brendanbond is already working on this.
Since Jan 24, 2024.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- next.js, react, typescript
Research direction
Start by reproducing the Next.js 14 build with the sample in src/app/formioreact/page.tsx and inspect the reported access to window in node_modules/formiojs/providers/storage/s3.js. Compare the listed @formio/react, @formio/js, and formiojs versions. Done means the sample builds without the server-side window error while still rendering the form.
Written by the indexing model from the issue text.
Description
I'm trying to use formio in next js, but I get the following error, but the form seems to render successfully.
Am I using formio correctly? Or does formio not support next js?
Sample Code:
"use client";
import { Form } from "@formio/react";
const Page = () => {
return (
<>
<Form src="https://examples.form.io/example" />
</>
);
};
export default Page;
Terminal:
⨯ node_modules\formiojs\providers\storage\s3.js (54:22) @ window
⨯ ReferenceError: window is not defined
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at eval (./src/app/formioreact/page.tsx:7:71)
at (ssr)/./src/app/formioreact/page.tsx (C:\Users\user\development\my-app\.next\server\app\formioreact\page.js:228:1)
at __webpack_require__ (C:\Users\user\development\my-app\.next\server\webpack-runtime.js:33:43)
at JSON.parse (<anonymous>)
null
package.json
{
"name": "my-app",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@formio/js": "^5.0.0-rc.37",
"@formio/react": "^5.3.0",
"formiojs": "^4.18.0",
"next": "14.0.4",
"react": "^18",
"react-dom": "^18"
},
"devDependencies": {
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"eslint": "^8",
"eslint-config-next": "14.0.4",
"typescript": "^5"
}
}
- Dominant language
- TypeScript
- Stars
- 371
- Forks
- 309
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from formio/react
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
-
onChange `modified` property remains false when file component is updatedMay be free again @ZenMasterJacob20011 claimed this 295 days ago, and no pull request is open. Open
-
FormBuilder onChange callback not triggered when options prop is providedMay be free again @Victoriya25 claimed this 337 days ago, and no pull request is open. Open
-
FormBuilder with OnChange broke textareaMay be free again @lane-formio claimed this 309 days ago, and no pull request is open. Open
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
milind-soni/OpenMausBot#6730 ·
Maintainers usually reply within 1 day
-
`@angular/[email protected]` depends on vulnerable Vite 7.3.7 - GHSA-p4f5-76q4-ffq7 (Critical RCE)Openarea: @angular/build
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
angular/angular-cli#34764 ·
Maintainers usually reply within 1 day
-
status/need-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
google-gemini/gemini-cli#30384 · 1 comment ·
Maintainers usually reply within 1 day
-
P2
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
area:image documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day