Render UI across server and client boundaries
Does a Next.js UI Library Need 'use client'? Check the Component Boundary
Decide when a Next.js UI component needs 'use client', where to wrap an unmarked import, and how to place a client provider.

A UI library does not need one blanket 'use client' decision. In the App Router, start with the component you are importing: a CSS-styled card can stay in a Server Component, while an interactive control may need a client boundary. If that control’s published entry point does not declare 'use client', wrap the import in a small Client Component rather than moving the whole page.
Check behavior, then check the entry point
Look for state, event handlers, effects, custom hooks, browser APIs, or React context. Those are reasons to examine the component’s client requirements; a package name alone tells you little. Next, inspect the entry point your application actually imports. A library author can mark a client-dependent entry point with 'use client', allowing you to render that component from a Server Component without adding your own wrapper. The Next.js Server and Client Components documentation also cautions that some bundlers strip the directive. A directive in a library’s source repository is therefore less useful to your integration than the directive in its published output.
Leave CSS-only UI on the server
daisyUI describes its components as CSS classes: using a card or button class does not itself introduce client-side behavior. Assuming Tailwind CSS is already configured, put its plugin after the Tailwind import in your global CSS:
app/globals.css
@import "tailwindcss";
@plugin "daisyui";
Then use the classes in an ordinary App Router page:
app/page.tsx
export default function Page() {
return (
<main>
<article className="card bg-base-100 shadow-sm">
<div className="card-body">
<h1 className="card-title">Featured items</h1>
<p>Browse this week's selection.</p>
<a className="btn btn-primary" href="/items">
Browse items
</a>
</div>
</article>
</main>
)
}
There is no 'use client' here: applying classes styles the markup but does not add state or a click handler. This CSS fragment is the relevant setup detail, not a complete Tailwind or daisyUI installation procedure; follow the setup appropriate to your project for those prerequisites.
Wrap an unmarked interactive import
Suppose an interactive component uses client-only features, but the entry point you import is unmarked. The following acme-carousel import is illustrative, not a real dependency or an installation instruction. Substitute a component and import that exist in your application.
app/components/carousel-boundary.tsx
'use client'
import { Carousel } from 'acme-carousel'
export default function CarouselBoundary() {
return <Carousel />
}
The page imports your boundary rather than importing the unmarked component directly. It can still render the daisyUI card on the server:
app/page.tsx
import CarouselBoundary from './components/carousel-boundary'
export default function Page() {
return (
<main>
<article className="card bg-base-100 shadow-sm">
<div className="card-body">
<h1 className="card-title">Featured items</h1>
<p>Browse this week's selection.</p>
<a className="btn btn-primary" href="/items">
Browse items
</a>
</div>
</article>
<CarouselBoundary />
</main>
)
}
'use client' establishes a module-graph boundary: the marked file’s imports and components it directly renders enter the client bundle. That is why the wrapper imports only what needs the boundary. It does not mean the route cannot provide initial HTML; Next.js describes an initial HTML preview followed by hydration that makes Client Components interactive.
Put a context provider in a client file
React context is not available in Server Components. If a library requires a context provider, put that provider in a Client Component and render it from a Server Component layout. This small local context demonstrates the boundary without pretending to be any library’s provider API:
app/components/ui-provider.tsx
'use client'
import { createContext, useContext, type ReactNode } from 'react'
const UiModeContext = createContext('standard')
export function UiProvider({ children }: { children: ReactNode }) {
return (
<UiModeContext.Provider value="standard">
{children}
</UiModeContext.Provider>
)
}
export function UiModeLabel() {
const mode = useContext(UiModeContext)
return <p>UI mode: {mode}</p>
}
app/layout.tsx
import { UiModeLabel, UiProvider } from './components/ui-provider'
import './globals.css'
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="en">
<body>
<UiProvider>
{children}
<UiModeLabel />
</UiProvider>
</body>
</html>
)
}
The layout remains a Server Component, while UiModeLabel is a client consumer inside the provider. Place a real provider as deeply as practical around the components that need it; Next.js recommends this so static portions of the Server Component tree remain easier to optimize. Use your library’s own instructions for its provider, styles, or registry—this local context is a boundary example, not a universal library configuration.
Pass server content through a client frame when useful
A client boundary does not have to own all the content visually inside it. For example, an interactive frame can accept server-rendered content as children:
app/components/expandable-frame.tsx
'use client'
import { useState, type ReactNode } from 'react'
export default function ExpandableFrame({
children,
}: {
children: ReactNode
}) {
const [open, setOpen] = useState(true)
return (
<section>
<button type="button" onClick={() => setOpen(!open)}>
{open ? 'Hide details' : 'Show details'}
</button>
{open && <div>{children}</div>}
</section>
)
}
In app/page.tsx, import ExpandableFrame and render <ExpandableFrame><ItemDetails /></ExpandableFrame>, where ItemDetails is a Server Component defined or imported by that page. The frame receives rendered output; it does not import ItemDetails into its client module graph. Use this composition when content belongs inside an interactive frame, not as an obligatory step for every UI library.
Once you replace the illustrative carousel import with your actual component, load the route. If a Server Component/client-only error appears, check that the interactive import is behind a Client Component boundary and review the error for other causes. Check that the daisyUI card receives its expected styling, then exercise the interactive control after hydration. If you use the optional patterns, confirm the provider’s client consumer works and the server-rendered content appears inside its client frame.




