Error thrown on NextJS
See original GitHub issueHello, I was trying useDapp with NextJS earlier today and as soon as I pasted all the basic example code I got this error:

Server Error
ReferenceError: window is not defined
This error happened while generating the page. Any console logs will be displayed in the terminal window.
Call Stack
getItem
file:///Users/fede/Documents/learning/usedapp+nextjs/usedapp-test-web/node_modules/@usedapp/core/dist/src/hooks/useLocalStorage.js (6:16)
<unknown>
file:///Users/fede/Documents/learning/usedapp+nextjs/usedapp-test-web/node_modules/@usedapp/core/dist/src/hooks/useLocalStorage.js (29:52)
useReducer
file:///Users/fede/Documents/learning/usedapp+nextjs/usedapp-test-web/node_modules/react-dom/cjs/react-dom-server.node.development.js (1537:57)
This article talks about this issue with NextJS https://medium.com/frontend-digest/why-is-window-not-defined-in-nextjs-44daf7b4604e , but there are many more you can google.
Is there a way to get a fix for this so useDapp becomes NextJS compatible or it does not make sense at all for you guys? Can I help?
Thanks for your time! Have a great day!
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (1 by maintainers)
Top Results From Across the Web
Advanced Features: Error Handling - Next.js
Handle errors in your Next.js app. ... Render a fallback UI after an error is thrown; Provide a way to reset the Application's...
Read more >reactjs - throw an error with a statusCode inside NextJs to test ...
I have been trying to create a page named errortest and inside that page, I want to throw an error with a given...
Read more >Testing and error handling patterns in Next.js - LogRocket Blog
This error is not visible in production, and it is only thrown when the development server is running. The error overlay often gives...
Read more >Handling API errors in Next.js - By Giancarlo Buomprisco
Learn how to write a Next.js middleware pipe to automatically and elegantly handle exceptions in your API functions.
Read more >Next.js API - Global Error Handler Example & Tutorial
This is an example Next.js API route handler that accepts HTTP GET requests and shows how to throw different exceptions that will be...
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 Free
Top 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
Seems to be happening to me on the upgrade to 0.4.0 and works again if I downgrade to 0.3.24. (My first day using the project, but seems like it might be related to new version)
@marekkirejczyk YES!!! It is!!! Amazing!! You guys are awesome! I had a little heart attack thought I hit a dead end, but this fix finally unblocked me. Thank you so much guys!