Skip to content
Back to skills

Server Components

ASecurity

RSC usage, "use client" directive, and Component Purity.

  • 8 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added September 8, 2026
ai-agentsgoreactnextjsapi

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 3 files and shows the line behind each finding

Scanned September 8, 2026

npx -y skills add ngxtm/devkit --skill server-components --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Server Components?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Server Components
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ngxtm-server-components/badge)](https://www.skillsdirectory.com/skills/ngxtm-server-components)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: Next.js Server Components
description: RSC usage, "use client" directive, and Component Purity.
metadata:
  labels: [nextjs, rsc, components]
  triggers:
    files: ['**/*.tsx', '**/*.jsx']
    keywords: [use client, Server Component, Client Component, hydration]
---

# Server & Client Components

## **Priority: P0 (CRITICAL)**

Next.js (App Router) uses React Server Components (RSC) by default.

## Server Components (Default)

- **Behavior**: Rendered on server, sent as HTML/Payload to client. Zero bundle size for included libs.
- **Capabilities**: Async/Await, Direct DB access, Secrets usage.
- **Restrictions**: No `useState`, `useEffect`, or Browser APIs (`window`, `localstorage`).

## Client Components

- **Directive**: Add `'use client'` at the VERY TOP of the file.
- **Usage**: Interactivity (`onClick`), State (`useState`), Lifecycle effects, Browser APIs.
- **Strategy**: Move Client Components to the leaves of the tree.
  - _Bad_: Making the root layout a Client Component.
  - _Good_: Wrapping a `<Button />` in a Client Component.

## Composition Patterns

- **Server-in-Client**: You cannot import a Server Component directly into a Client Component.
  - _Fix_: Pass Server Component as `children` prop to the Client Component.

```tsx
// ClientWrapper.tsx
'use client';
export default function ClientWrapper({ children }) {
  return <div>{children}</div>;
}

// Page.tsx (Server)
<ClientWrapper>
  <ServerComponent />
</ClientWrapper>;
```

## Anti-Patterns

- **Poisoning**: Importing server-only secrets into Client Components (Use `server-only` package to prevent).
- **Over-fetching**: Passing large data props to Client Components (Serialization cost). Only pass IDs if possible.

Files in this skill

  • SKILL.md1.7 KB
  • references/REFERENCE.md334 B
  • references/component-patterns.md3.7 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…