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

Issue during SSR, fetch not defined #6

Closed
Evertt opened this issue Mar 16, 2021 · 4 comments
Closed

Issue during SSR, fetch not defined #6

Evertt opened this issue Mar 16, 2021 · 4 comments

Comments

@Evertt
Copy link

Evertt commented Mar 16, 2021

This issue happens in SvelteKit and I presume also in Sapper.

This issue could relatively easily be mitigated if createSWR() wasn't automatically called. Then a developer like me could choose not to call it during SSR, or to call it with a special fetcher.

@asv7c2
Copy link

asv7c2 commented Apr 10, 2021

Same problem.

@ConsoleTVs
Copy link
Owner

Hey guys, can we elaborate a bit on the problem? I have never used ssr. What is the intention of it, should it automatically fetch on server first and then client?

@Evertt
Copy link
Author

Evertt commented Apr 10, 2021

Yeah the idea is that it fetches on the server first so that it can deliver pre-rendered html to the client. And after that the client takes over.

So on the server I want to be able to configure swr to use node-fetch.

@ConsoleTVs
Copy link
Owner

Hey guys, got an update for you all.

I am no expert at SSR, and since sveltekit is still in beta I don't want to get into it.

So for now, what I made is make it work with any SSR solution but without actually fetching on the server. Instead, sswr will only fetch on the client.

Hope this fix works for your current applications. I am happy to get any PR. This library is fairly simple at the end of the day.

I've also fixed a few typescript generic paramenters. Please try version: 1.2.0

Have a nice day!

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

3 participants