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

Q: How to use dynamic to disable SSR? #70

Open
Pet3ris opened this issue Aug 31, 2022 · 0 comments
Open

Q: How to use dynamic to disable SSR? #70

Pet3ris opened this issue Aug 31, 2022 · 0 comments

Comments

@Pet3ris
Copy link

Pet3ris commented Aug 31, 2022

I’m using rescript-request https://github.com/bloodyowl/rescript-request 3 to issue XMLHttp requests in my Vercel site. Unfortunately, Vercel attempts to aggressively use server side rendering and XMLHttp has no implementation in node.js.

As a result, I get the following error:

Error occurred prerendering page "mypage". Read more: https://nextjs.org/docs/messages/prerender-error
ReferenceError: XMLHttpRequest is not defined

There is normally a simple fix for this, just import the module with SSR disabled, like so: Advanced Features: Dynamic Import | Next.js 1. I can see that the template does seem to have support for dynamic:

external dynamic: (unit => Js.Promise.t<'a>, options) => 'a = "default"
.

But how do I put this together?

In particular, I don’t seem to have control over where the underlying rescript-request module gets imported and therefore am not sure how to annotate that import with dynamic.

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