Next.js Discord

Discord Forum

Error in next build, useContext and sessionStorage

Unanswered
subscr posted this in #help-forum
Open in Discord
hello guys, when i execute npm run build, i recived this errors:
TypeError: Cannot read properties of null (reading 'useContext')
-----------------
Error occurred prerendering page "/404". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of null (reading 'useContext')
-----------------
TypeError: Cannot read properties of null (reading 'useContext')
-----------------
Error occurred prerendering page "/500". Read more: https://nextjs.org/docs/messages/prerender-error

TypeError: Cannot read properties of null (reading 'useContext')
----------------
ReferenceError: sessionStorage is not defined
----------------
Error occurred prerendering page "/dashboard". Read more: https://nextjs.org/docs/messages/prerender-error

ReferenceError: sessionStorage is not defined

6 Replies

i have this with useContext
sessionstorage, in components with 'use client'
buhhhh
@subscr did you ever fix this?
even if you're using use client you can use web apis only in useEffect or events (like onClick)