agentleFS
vibestackdevvibestackdev/vibe-stack/.cursor/rules/server-vs-client-components.mdc

vibe-stack / rules

Cursor rule8 starsChanged 8 months agoMITView on GitHub

Distinguishing between Server and Client Components

The file

Files
server-vs-client-components.mdc
---
description: Distinguishing between Server and Client Components
globs: ["**/*.tsx", "**/*.jsx"]
---

# Server vs Client Components

Decision Tree (ALWAYS follow this order):
1. Can this component run as a Server Component? DEFAULT: YES
2. Does it use: `useState`, `useEffect`, `useRef`, event handlers, or browser APIs?
   → ONLY THEN add `'use client'`
3. Push `'use client'` to the smallest possible LEAF component

Optimization pattern:
- Server Component: data fetching, layout, most of the tree
- Client Component: only the interactive parts (button, form input, dropdown)

❌ Anti-pattern (Avoid):
```tsx
'use client'  
export default function ProductPage({ id }) {
  // Uses server fetch — should be Server Component
  const [product, setProduct] = useState(null)
  useEffect(() => { fetch(`/api/products/${id}`).then(...) }, [])
}
```

✅ Correct:
```tsx
// Server Component — no 'use client' needed for data fetching
export default async function ProductPage({ id }) {
  const product = await getProduct(id) 
}
```

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.