-
Notifications
You must be signed in to change notification settings - Fork 19
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
Only add to window if window exists #42
Conversation
This prevents `window is not defined` error when using SSR frameworks such as Next.js.
how do i "npm install suggestions" with this pull request? next js deployment installs the version without this change and errors out my build |
That's actually exactly why I made this PR. I think you can import this library using Next.js dynamic imports to get around the issue for now. https://nextjs.org/docs/advanced-features/dynamic-import#with-no-ssr. You could also fork this repo and merge this PR in your fork and use your forked version. Last release for this library was 13 months ago, so I'm not sure if it's being maintained anymore. |
I could not get around the issue with the dynamic import (works on dev, but vercel rebuilds the node_modules folder based on package.json). The vercel builder still throws an error on deployment. I was able to deploy my website through firebase hosting though. Here is a link to a simple deployment method if you are a firebase user. NextJS and Firebase Hosting Use |
What do you mean by this? You shouldn't be editing the files inside of the Specifying |
Thanks for the PR! |
Published |
This fixes the `window is not defined` issue when using `mapbox-gl-geocoder` with an SSR app. PR in the `suggestions` library that fixes the issue tristen/suggestions#42.
This prevents
window is not defined
error when using SSR frameworks such as Next.js.Sample Next.js app that demonstrates error when trying to import
suggestions
module: https://github.com/SamSamskies/suggestions-demoScreenshot of error: