-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
[Next 13 App Dir]: "You're importing a component that needs" - Even when I'm not rendering one. #2632
Comments
Possibly a duplicate of vercel/next.js#44039? |
Its the same bug but two very different use cases. Both are most likely solved the same way: stub the client only hooks and make them throw errors if called on server, do not prematurely crash the app. Effectively, SWR with special keys is now useless for ssr if this is not changed. I'm afraid many other libraries are too. |
Any movement possible on this? |
+1. This is the only thing holding me back being able to use the appDir feature. A fix for this would be greatly appreciated. 👍 |
vercel/next.js#49714 (comment) I think But I agree that |
@shuding I definitely agree on useSWR, however I still think that Next shoud be able to tree shake then analyse when checking for client directives, not the other way around. Great to see this being moved as our library |
Verify canary release
Provide environment information
Which area(s) of Next.js are affected? (leave empty if unsure)
App directory (appDir: true)
Link to the code that reproduces this issue
https://github.com/sannajammeh/appdir-swr-fail
To Reproduce
pnpm install
pnpm run dev
useRef
.Describe the Bug
When any library using client only hooks is imported the entire page errors. No rendering of client components occurs. Simply importing a function from a library that happens to have a client only hook crashes it.
Expected Behavior
The app should render as no client hooks are really used. I simply need the
unstable_serialize
function to perform some ssr serialization on the server then passing to SWR config.The desired behavior should be crashing the app once a hook is called, i.e stub the hooks on the server only react and make them throw errors. I dont think blocking the app from running is a good decision here.
Which browser are you using? (if relevant)
No response
How are you deploying your application? (if relevant)
No response
The text was updated successfully, but these errors were encountered: