Next.js Error: window is not defined (FIXED)

preview_player
Показать описание
Hi, I'm Wesley. I'm a brand ambassador for Kinde (paid sponsorship).

👉 Discord: all my courses have a private Discord where I actively participate

⏱️ Timestamps:
0:00 Explanation

#webdevelopment #coding #programming
Рекомендации по теме
Комментарии
Автор

Thank you so so much!! Lazy loading fixed my issue perfectly ❤❤

amelia.s
Автор

Thanks a ton! lazy loading worked perfectly!

FarzadKhan-lljw
Автор

Getting 'Reference error : document is not defined', cause i am using one outside npm package (client side) in my nextjs 14 app. Tried to make component client side by using "use client" also. This is probably because of nextjs prerenders everything in server. How to fix it. Please help

reactjs
Автор

Very helpful, the "dynamic" was what helped me!!

natemueller
Автор

Let's say I want to render a component based on the window.location and I want to use this UseEffect method how can I use it to render conditionally

__Yash__
Автор

This was immensely helpful, Thank you !

FaizalSyed
Автор

Finnaly a video that solves my problem. 3rd solution from video is the one! Thank you man!

franbrankovic
Автор

hello, i have a problem with nextjs, when i start my project the message display in my browser. this message is `Internal Server Error` . can you help me please??

hadiqadimi
Автор

hahahah YES !!! After kinda 90 minutes i found your video, third option helped, and can now deploy successfully to vercel again, after so many atempts! Its even on your given CV page i am working on xD

jannickpedersen
Автор

if (typeof window !== "undefined") { } works! Thank you

meka
Автор

Very helpful. Also Can you please tell us how to handle this kind of error for local storage in next js 13? In my case, local storage is in the redux slice. I tried with use client that doesn't work, also tried with global.localstorage that doesn't work also.

sudiptokumarmitra
Автор

i don't like add this "use client", can you fix error 'You're importing a component that needs useState. It only works in a Client Component but none of its parents are marked with "use client", so they're Server Components by default ' pls

nguyenthuong