Skip to content
Back to skills

React Patterns

ASecurity

React and Next.js development patterns for building modern web applications. Use when implementing components, pages, hooks, state management, data fetching, forms, and client-side authentication. Covers TypeScript, App Router, Server Components, and best practices.

  • 13 stars
  • 0 votes
  • 0 copies
  • 2 views
  • Added February 7, 2026
developmenttypescriptreactnextjsapi

Works with

  • cli
  • api

Security analysis

A100/100

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

Scanned February 12, 2026

npx -y skills add shahtuyakov/claude-setup --skill react-patterns --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of React Patterns?

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

Security grade badge for React Patterns
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/shahtuyakov-react-patterns/badge)](https://www.skillsdirectory.com/skills/shahtuyakov-react-patterns)

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: react-patterns
description: React and Next.js development patterns for building modern web applications. Use when implementing components, pages, hooks, state management, data fetching, forms, and client-side authentication. Covers TypeScript, App Router, Server Components, and best practices.
---

# React Patterns

Modern React and Next.js patterns with TypeScript.

## Framework Selection

| Setup | Best For | Use When |
|-------|----------|----------|
| Next.js App Router | Full-stack, SSR/SSG | SEO matters, need server components |
| Next.js Pages Router | Simpler SSR | Legacy project, simpler mental model |
| Vite + React | SPA, client-only | No SSR needed, fastest dev experience |
| Create React App | Legacy | Avoid for new projects |

## Reference Files

| Topic | Load | Use When |
|-------|------|----------|
| Project structure | `references/project-structure.md` | Setting up or organizing code |
| Components | `references/components.md` | Building UI components |
| State management | `references/state-management.md` | Managing app/component state |
| Data fetching | `references/data-fetching.md` | API calls, server data |
| Forms | `references/forms.md` | Form handling and validation |
| Auth (client) | `references/auth-client.md` | Client-side authentication |

## Quick Start Patterns

### Next.js App Router Page

```typescript
// app/users/page.tsx
import { getUsers } from '@/lib/api';
import { UserList } from '@/components/users/UserList';

export default async function UsersPage() {
  const users = await getUsers();

  return (
    <main className="container mx-auto py-8">
      <h1 className="text-2xl font-bold mb-6">Users</h1>
      <UserList users={users} />
    </main>
  );
}
```

### Client Component

```typescript
'use client';

import { useState } from 'react';

interface CounterProps {
  initialCount?: number;
}

export function Counter({ initialCount = 0 }: CounterProps) {
  const [count, setCount] = useState(initialCount);

  return (
    <button onClick={() => setCount(c => c + 1)}>
      Count: {count}
    </button>
  );
}
```

### API Route (App Router)

```typescript
// app/api/users/route.ts
import { NextResponse } from 'next/server';

export async function GET() {
  const users = await db.user.findMany();
  return NextResponse.json(users);
}

export async function POST(request: Request) {
  const body = await request.json();
  const user = await db.user.create({ data: body });
  return NextResponse.json(user, { status: 201 });
}
```

## Essential Packages

| Package | Purpose |
|---------|---------|
| `typescript` | Type safety |
| `tailwindcss` | Styling |
| `@tanstack/react-query` | Server state |
| `zustand` | Client state |
| `react-hook-form` | Forms |
| `zod` | Validation |
| `framer-motion` | Animations |
| `lucide-react` | Icons |

## TypeScript Rules

1. **Explicit prop types** - Interface for every component
2. **No `any`** - Use `unknown` if needed
3. **Strict mode** - Enable in tsconfig
4. **Type imports** - Use `import type` when possible

## Code Quality Rules

1. **Functional components** - No class components
2. **Named exports** - Except page defaults
3. **Small files** - One component per file
4. **Custom hooks** - Extract reusable logic
5. **Error boundaries** - Wrap key sections
6. **Loading states** - Always handle loading/error

Files in this skill

  • SKILL.md3.3 KB
  • references/auth-client.md11.6 KB
  • references/components.md6.3 KB
  • references/data-fetching.md9.3 KB
  • references/forms.md9.2 KB
  • references/project-structure.md5.8 KB
  • references/state-management.md7.4 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…