Skip to content

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

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

Add "client-only" #2221

Closed
shuding opened this issue Nov 1, 2022 · 2 comments
Closed

Add "client-only" #2221

shuding opened this issue Nov 1, 2022 · 2 comments
Labels
discussion Discussion around current or proposed behavior

Comments

@shuding
Copy link
Member

shuding commented Nov 1, 2022

SWR is highly depending on client React features like state, context, effect, etc. so it can't be used in server components. The best way to avoid this is to add a "client-only" import to the core.

@shuding shuding added the discussion Discussion around current or proposed behavior label Nov 1, 2022
@zenflow
Copy link

zenflow commented Nov 4, 2022

Then you need a different API for fetching data in server components. ☹️

@shuding
Copy link
Member Author

shuding commented Nov 23, 2022

SWR can't run on the server side (e.g. during SSR), that's the case from the beginning. And server components won't be hydrated on the client, so everything inside them will not run on the browser.

One way to think about it is that you can't run useSWR inside getServerSideProps.

@vercel vercel locked and limited conversation to collaborators Dec 15, 2022
@koba04 koba04 converted this issue into discussion #2294 Dec 15, 2022

This issue was moved to a discussion.

You can continue the conversation there. Go to discussion →

Labels
discussion Discussion around current or proposed behavior
Projects
None yet
Development

No branches or pull requests

2 participants