Facing a ReferenceError: self is not defined while installing on NextJS
See original GitHub issueHi there,
Thank you for creating such a beautiful piece of QRCode art! Really thankful for the project!
Sadly, when I had attempted to install and run QR-code-styling, the code seem to be broken.
Primarily, the issue came up when I started to run an import QRCodeStyling from "qr-code-styling";
in my NextJS setup.
- “next”: “latest”,
- “qr-code-styling”: “^1.6.0-rc.1”, (Also tried v1.5.0 but also didn’t work)
- “react”: “^17.0.2”,
Here are the error messages of ReferenceError: self is not defined
:
Hope you may help assist with the issue. Thank you so much! Cheers!
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
Top Results From Across the Web
reactjs - Why am I getting ReferenceError: self is not defined ...
The error occurs because the library requires Web APIs to work, which are not available when Next.js pre-renders the page on the server-side ......
Read more >middlewares - ReferenceError: self is not defined · Issue #38149
I'm experiencing the same issue. Upgraded to Next.js v12.2 and migrated the middleware accordingly. But builds are breaking with the exact same ...
Read more >self is not defined nextjs | The AI Search Engine You Control
The error occurs because the library requires Web APIs to work, which are not available when Next.js pre-renders the page on the server-side....
Read more >self is not defined when I import a client-side library?-Reactjs
The error occurs because the library requires Web APIs to work, which are not available when Next.js pre-renders the page on the server-side....
Read more >Is there is any possibility to have Web Amity UI Kit working ...
The error we've been facing is always the same for UI Kit from the source code ... 2 ReferenceError: Element is not defined...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I got around this issue by using ES6 dynamic imports : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#dynamic_imports
Example:
I faced this issue as well my solution uses dynamic import from NEXTJS
https://nextjs.org/docs/advanced-features/dynamic-import
So Create a component
QR.tsx
(whatever really)and on you Page imported like, important bit is to disable
ssr