From harness-claude
Guides Next.js Server Components for server-side data fetching, backend access, and client boundaries to reduce JS bundles and secure credentials.
npx claudepluginhub intense-visions/harness-engineering --plugin harness-claudeThis skill uses the workspace's default tool permissions.
> Keep data fetching and heavy logic on the server; push interactivity to the client only where needed
Guides using Next.js Server Components for data fetching, direct DB access, Server vs Client decisions, and Server Actions in data-intensive apps.
Implements React Server Components to run on server, eliminate client JavaScript, and enable direct database access. Use for Next.js App Router data fetching without APIs.
Guides React Server Components in Next.js: server vs client distinction, 'use client' directive, component boundaries, composition patterns, and data fetching.
Share bugs, ideas, or general feedback.
Keep data fetching and heavy logic on the server; push interactivity to the client only where needed
'use client' boundary in a component treeapp/ is a Server Component by default — no directive needed. Add 'use client' only when the component uses hooks, browser APIs, or event handlers.async — await data directly inside the component body instead of using useEffect.fs, secret env vars) into Client Components. Use the server-only package to enforce this at build time.'use client' as close to the leaf as possible — this minimizes the client bundle.children prop (composition), but cannot import a Server Component module directly.React.cache() to deduplicate fetch calls across a request when multiple Server Components fetch the same data.import 'server-only' to prevent accidental client-side imports.// app/dashboard/page.tsx — Server Component (async, no directive)
import { db } from '@/lib/db'; // server-only module — safe here
import { MetricCard } from './metric-card'; // Client Component receives data as props
export default async function DashboardPage() {
const metrics = await db.query.metrics.findMany();
return (
<div>
{metrics.map(m => <MetricCard key={m.id} metric={m} />)}
</div>
);
}
// app/dashboard/metric-card.tsx — Client Component
'use client';
import { useState } from 'react';
export function MetricCard({ metric }: { metric: Metric }) {
const [expanded, setExpanded] = useState(false);
return <div onClick={() => setExpanded(e => !e)}>{metric.label}</div>;
}
React Server Components (RSC) render on the server and send HTML + a serialized component tree to the client. They never ship their module code to the browser, so they can safely import server-only dependencies.
The boundary model: 'use client' marks a module as the root of a client subtree. All modules imported by that module are also bundled for the client — the directive propagates downward through the import graph. This is why pushing the boundary toward leaves reduces bundle size.
Serialization constraints: Props crossing the server→client boundary must be serializable (strings, numbers, plain objects, arrays). Functions, class instances, and Promises cannot be passed directly as props to Client Components (Promises can be passed to Suspense-aware Client Components via use()).
Common mistakes:
'use client' to a file that imports a database client — the database client ends up in the bundleuseEffect when a Server Component parent could fetch it directlyPerformance note: Server Components reduce Time to First Byte (TTFB) for data-heavy pages because HTML arrives pre-rendered. Interactivity is hydrated progressively.
https://nextjs.org/docs/app/building-your-application/rendering/server-components