Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ReferenceError: localStorage is not defined #3

Closed
dongree opened this issue Jul 25, 2023 · 1 comment
Closed

ReferenceError: localStorage is not defined #3

dongree opened this issue Jul 25, 2023 · 1 comment

Comments

@dongree
Copy link
Member

dongree commented Jul 25, 2023

다음과 같은 에러 뜨면서 build 안됨

dongree added a commit that referenced this issue Jul 25, 2023
@dongree
Copy link
Member Author

dongree commented Jul 25, 2023

Next.js는 CSR전에 SSR을 수행한다.
Server-side 에선 Client-side에 존재하는 window 객체를 사용할 수 없다.

if(typeof window !== 'undefined'){}

다음 조건문을 달아 server-side에서 window 객체를 호출하지 못하도록 해 해결한다.

@dongree dongree closed this as completed Jul 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant