← Browse

@majiayu000/next-16

B

Next.js 16.1+ App Router patterns. Use when working with pages, routing, caching, params, or middleware.

skillclaude

Install

agr install @majiayu000/next-16 --target claude

Writes 2 files into .claude/skills/, pinned to git-f73ccb78.

  • .claude/skills/next-16/SKILL.md
  • .claude/skills/next-16/metadata.json

Document


name: next-16 description: Next.js 16.1+ App Router patterns. Use when working with pages, routing, caching, params, or middleware.

Next.js 16.1+

Async params

Type params and searchParams as Promise<>, await in component body.

examples/async-params.tsx

Caching Overview

Enable cacheComponents: true in next.config.ts.

DirectiveRuntime APIsStorageUse Case
"use cache"NoIn-memoryStatic shared content
"use cache: private"YesBrowser onlyUser-specific data
"use cache: remote"NoRemote cacheMulti-instance shared

"use cache"

Cache routes, components, or functions. Data fetching cached as part of static shell.

Serialization Rules

Supported: primitives, plain objects, arrays, Date, Map, Set, React elements (pass-through only)

Unsupported: class instances, functions (except pass-through), Symbols, WeakMap/WeakSet

Pass-Through Pattern

Accept non-serializable values (children, actions) without introspecting them.

Runtime API Constraint

Cannot access cookies(), headers(), searchParams inside cached scope. Read outside and pass as args.

examples/use-cache.tsx

"use cache: private"

Allows runtime APIs inside cache. Results cached in browser memory only, never on server.

Constraints:

  • Executes on every server render
  • Excluded from static shell
  • cacheLife stale time must be ≥30s

examples/use-cache-private.tsx

"use cache: remote"

Stores output in remote cache. Durable across instances/deployments.

Use when:

  • Rate-limited APIs
  • Slow/expensive backends
  • Serverless (ephemeral memory)

Avoid when:

  • Fast operations (<50ms)
  • High-cardinality cache keys
  • Frequently changing data

examples/use-cache-remote.tsx

"use client"

Marks client-side entry point. Add at top of file before imports.

'use client'

import { useState } from 'react'

export default function Counter() {
  const [count, setCount] = useState(0)
  return <button onClick={() => setCount(c => c + 1)}>{count}</button>
}

Props must be serializable. Functions cannot be passed from server to client.

"use server"

Marks Server Actions. Can be file-level or inline.

// File-level
'use server'
export async function createUser(formData: FormData) {
  await db.user.create({ data: Object.fromEntries(formData) })
  revalidatePath('/users')
}

// Inline
async function submitForm(formData: FormData) {
  'use server'
  await saveData(formData)
}

Invalidation

import { cacheTag, revalidateTag, updateTag } from 'next/cache'

// Tag cached data
async function getData() {
  'use cache'
  cacheTag('products')
  return fetch('/api/products')
}

// Invalidate
revalidateTag('products', 'hours')  // SWR-style with profile
updateTag('products')               // Server Actions: immediate

Profiles: 'hours' (1h), 'days' (1d), 'weeks' (1w), 'max' (1y)

Cache Lifetime

import { cacheLife } from 'next/cache'

async function getData() {
  'use cache'
  cacheLife('hours')  // Profile shorthand
  // or
  cacheLife({ stale: 300, revalidate: 900, expire: 3600 })
}

Proxy (auth/routing)

Use proxy.ts instead of middleware.ts. Runs on Node.js runtime.

examples/proxy.ts

Common Mistakes

❌ Wrong✅ Correct
'use cache' with cookies() insideRead cookies outside, pass as arg
Creating JSX inside cache, passing to clientPass data to client, render there
middleware.tsproxy.ts
revalidateTag(tag)revalidateTag(tag, 'hours')
Cache high-cardinality keysCache low-cardinality, filter in-memory

Repository README

Describes majiayu000/claude-skill-registry-data as a whole, which may contain artifacts other than this one. Where this artifact had no useful description of its own, its summary was taken from here.

Claude Skill Registry (Data)

This repo contains the archived skill contents (the heavy, browsable skill files).

Canonical layout

  • Category folders at repo root (e.g. development/, documents/, data/, ...)
  • Each skill lives under a category: <category>/<skill>/SKILL.md + <category>/<skill>/metadata.json
  • Case conflicts are resolved with {name}-{owner}-{repo} suffixes (fallback: -{short-hash}).

Archive status

  • Live badges above are sourced from claude-skill-registry-core stats.json.
  • Counts in this README are intentionally dynamic, not hardcoded.
  • If the badges look stale, refresh the core build/index pipeline rather than editing numbers here.

Where the index + site live

Trustgrade B

  • passBody integrity

    Whether the stored document is plausibly the kind of file the artifact declares, rather than something fetched by mistake.

  • passType matchnot applicable to this artifact type

    Whether the artifact is really the kind of thing its metadata claims it is.

  • passFreshness

    How long since the source repository was last pushed to.

  • passPrompt injection

    Scans the artifact's own text for instructions aimed at your agent rather than at you.

  • warnLicenseno SPDX license detected

    Whether the source repository declares an SPDX license permissive enough to redistribute.

How the grade is calculated

Each check contributes 0 points when it passes, 1 when it warns, and 2 when it fails. The total maps to a letter:

  • Aevery check passed
  • Bone warning
  • Ctwo warnings
  • Dprompt injection or body integrity failed, or three warnings
  • Fone of those failed, and something else is wrong

These are automated hygiene checks, not a security audit, and not a dependency or vulnerability scan. A grade of A means nothing was flagged — not that the artifact is safe.

Versions

  • git-f73ccb78f4032026-07-31