Thursday 24 August 2023

How to create react UI library having mix of client and server components?

I want to create a simple library that exports some server components and some client components. It should be compatible with Nextjs app router. But when I build, the client components don't work.

I tried building the library with tsup. I can fix the client components issue by adding

 banner: {
     js: `"use client";`,
 },

to the tsup.config.ts. However, once I do that, server components break.



from How to create react UI library having mix of client and server components?

No comments:

Post a Comment