- Add 8 new skills (62 total, up from 58) - Official Anthropic skills: docx, pdf, pptx, xlsx, brand-guidelines, internal-comms - Vercel Labs skills: react-best-practices, web-design-guidelines - Implement dual-versioning: -official/-anthropic and -community suffixes - Update README with new skill registry and credits - Regenerate skills_index.json (62 skills validated) - Add comprehensive walkthrough.md BREAKING CHANGE: Document skills (docx/pdf/pptx/xlsx) renamed with version suffixes
27 lines
681 B
Markdown
27 lines
681 B
Markdown
---
|
|
title: Per-Request Deduplication with React.cache()
|
|
impact: MEDIUM
|
|
impactDescription: deduplicates within request
|
|
tags: server, cache, react-cache, deduplication
|
|
---
|
|
|
|
## Per-Request Deduplication with React.cache()
|
|
|
|
Use `React.cache()` for server-side request deduplication. Authentication and database queries benefit most.
|
|
|
|
**Usage:**
|
|
|
|
```typescript
|
|
import { cache } from 'react'
|
|
|
|
export const getCurrentUser = cache(async () => {
|
|
const session = await auth()
|
|
if (!session?.user?.id) return null
|
|
return await db.user.findUnique({
|
|
where: { id: session.user.id }
|
|
})
|
|
})
|
|
```
|
|
|
|
Within a single request, multiple calls to `getCurrentUser()` execute the query only once.
|