Styled components in component library #3736
-
|
Hi I've searched long and far, but could not find much information about this topic. I have a component library that is distributed through an npm package. This library uses The component library is then consumed in a separate NextJS project. Currently I am running into issues regarding SSR, using the The problems I am running into:
My main question is; Does anybody know of any examples of similar setups? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
|
I don't think is specifically a Nextjs problem. I have had the same problem in non next applications. I am sorry but I don't have a solution to this. But keeping an eye on this |
Beta Was this translation helpful? Give feedback.
-
|
Did you figure it out? I have the same issue @mrcrazylee |
Beta Was this translation helpful? Give feedback.
-
|
The most common cause of issues when using styled-components in a component library is multiple instances of the library being bundled. Ensure that:
For SSR with Next.js, the consuming app needs its own styled-components registry setup regardless of the library. |
Beta Was this translation helpful? Give feedback.
The most common cause of issues when using styled-components in a component library is multiple instances of the library being bundled. Ensure that:
styled-componentsis apeerDependencyin your library (which you have)npm ls styled-componentsto verifydisplayNameand component IDs generated at build time must be deterministic and not conflict with the ones baked into the libraryFor SSR with Next.js, the consuming app needs its own styled-components registry setup regardless of the lib…