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

"Window is not defined" error when extending on NextJS. #86

Closed
akchro opened this issue Aug 6, 2023 · 2 comments
Closed

"Window is not defined" error when extending on NextJS. #86

akchro opened this issue Aug 6, 2023 · 2 comments

Comments

@akchro
Copy link

akchro commented Aug 6, 2023

Describe the bug
To use three-globe on react-three-fiber, I have to use react-three-fiber's extend function to import it. Doing so causes a "window is not defined" error that does not break the dev environment, but restricts next build.

To Reproduce
Steps to reproduce the behavior:

  1. Create a NextJS app
  2. I a component file, import ThreeGlobe from "three-globe";
  3. After importing, extend({ThreeGlobe})

Expected behavior
three-globe imported without any errors

Screenshots
Error logs:
image

Desktop (please complete the following information):

  • OS: MacOS Monterey
  • Browser: Chrome
  • Version: Version 115.0.5790.114 (Official Build) (arm64)

Smartphone (please complete the following information):
Not Tested on smartphone

Additional context
N/A

@vasturiano
Copy link
Owner

This module is not really compatible with SSR. You probably need to disable it in next.

@akchro
Copy link
Author

akchro commented Aug 9, 2023

I tried using a dynamic import and also tried "use client". I still get a window not defined error. Any other ways to disable ssr?

Edit: I used dynamic import wrong. I got it fixed.

@akchro akchro closed this as completed Aug 9, 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

2 participants