You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Provide a way to specify which vendor component packages are client components. This would allow server components to import vendor client components more easily.
Non-Goals
No response
Background
Currently, when you import a client component from a vendor package into your server component, like this:
Error: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more: https://nextjs.org/docs/messages/context-in-server-component
This error happened while generating the page. Any console logs will be displayed in the terminal window.
This is because not all vendor component libraries have 'use client' explicitly defined. One solution is to draw the client boundary
However, both solutions are far from ideal as they require creating additional files or client separation that may not be semantically related to your application.
Proposal
A new option to next.config.js: clientPackages that defines client boundary for vendor component
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Goals
Provide a way to specify which vendor component packages are client components. This would allow server components to import vendor client components more easily.
Non-Goals
No response
Background
Currently, when you import a client component from a vendor package into your server component, like this:
you will encounter the error:
This is because not all vendor component libraries have 'use client' explicitly defined. One solution is to draw the client boundary
or to create a file that exports the components with 'use client' directive.
However, both solutions are far from ideal as they require creating additional files or client separation that may not be semantically related to your application.
Proposal
A new option to
next.config.js
:clientPackages
that defines client boundary for vendor componentBeta Was this translation helpful? Give feedback.
All reactions