next-cache-components
Skill3.1k starsChanged 9 months agoMITView on GitHub
Next.js 16 Cache Components - PPR, use cache directive, cacheLife, cacheTag, updateTag
22 other projects use a version of this, 9 of them edited.
Trending
Quiet since March.about the whole repository
Most recently taken up by
- imMamdouhaboammar/openreviewword for word, first seen Nov 15, 2026
- figueroaignacio/ignaciofigueroa.devedited, first seen Nov 8, 2026
- ever-co/ever-worksedited, first seen Nov 8, 2026
- ever-works/ever-worksedited, first seen Nov 5, 2026
- arkantrust/next-skillsword for word, first seen Oct 20, 2026
- davidanthonyn/claude-skillsword for word, first seen Oct 20, 2026
Who's talking about TheEdoRan/next-safe-action
- vercel/next.js“"Server Actions must be async functions." being reported incorrectly”GitHub · Nov 5, 2024 · 13 reactions
- next-safe-action/next-safe-action“[BUG] `onError` called on redirects if it was called previously”GitHub · Dec 1, 2024 · 7 reactions
- next-safe-action/next-safe-action“[BUG] TypeScript issue with parsedInput in useAction Hook”GitHub · Jun 16, 2024 · 3 reactions
- next-safe-action/next-safe-action“[BUG] Not possible to handle errors that are not instance of Error”GitHub · Jan 10, 2025 · 2 reactions
- airjp73/rvf“Fix zod-form-data schema output type that are using `stripEmpty`”GitHub · Jun 10, 2025 · 1 reactions
The biggest 5 of 50 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 50
Talked about on GitHub (50 times).
On GitHub · 50
- Nov 5, 2024"Server Actions must be async functions." being reported incorrectly — vercel/next.js13 reactions · 5 comments
- Dec 1, 2024[BUG] `onError` called on redirects if it was called previously — next-safe-action/next-safe-action7 reactions · 4 comments
- Jun 16, 2024[BUG] TypeScript issue with parsedInput in useAction Hook — next-safe-action/next-safe-action3 reactions · 8 comments
- Jan 10, 2025[BUG] Not possible to handle errors that are not instance of Error — next-safe-action/next-safe-action2 reactions · 3 comments
- Jun 10, 2025Fix zod-form-data schema output type that are using `stripEmpty` — airjp73/rvf1 reaction · 4 comments
45 more on GitHub
- May 20, 2025Zod v4 support — next-safe-action/next-safe-action1 reaction · 1 comment
- Feb 19, 2025Fix `zfd.formData` input type — airjp73/rvf1 reaction · 3 comments
- Mar 8, 2024[ASK] Error: Cannot access 'action' before initialization — next-safe-action/next-safe-action1 reaction · 3 comments
- Oct 11, 2023Dist files contain incorrect types — next-safe-action/next-safe-action1 reaction · 2 comments
- Mar 25, 2026Bump next-safe-action from 7.10.8 to 8.1.8 — ChazWyllie/kairofit0 reactions · 1 comment
- Mar 15, 2026chore(deps): bump the npm-dependencies group across 1 directory with 14 updates — startberlin/cockpit0 reactions · 2 comments
- Mar 4, 2026[BUG] `returnValidationErrors` called from middleware catch block throws instead of returning `validationErrors` — next-safe-action/next-safe-action0 reactions
- Mar 1, 2026build(deps): bump next-safe-action from 8.0.11 to 8.1.4 — wuyuan1992/react-components0 reactions · 2 comments
- Mar 1, 2026chore(deps): bump the npm-dependencies group across 1 directory with 12 updates — startberlin/cockpit0 reactions · 2 comments
- Feb 28, 2026Bump next-safe-action from 8.0.11 to 8.1.4 — rifandani/feature-flag0 reactions
- Feb 27, 2026Bump next-safe-action from 8.0.11 to 8.1.4 — joehentges/pendulem0 reactions
- Feb 11, 2026[Module Listing Request]: `nuxt-safe-action` — nuxt/modules0 reactions · 2 comments
- Dec 16, 2025Bump next-safe-action from 7.10.8 to 8.0.11 — hiteshhJ/ticketing-app0 reactions
- Oct 29, 2025Bump next-safe-action from 7.10.2 to 8.0.11 — akunpbhanz-lgtm/starter0 reactions · 1 comment
- Sep 30, 2025Bump next-safe-action from 7.10.8 to 8.0.11 — eersnington/diff00 reactions · 2 comments
- Sep 8, 2025Bump next-safe-action from 8.0.10 to 8.0.11 — joehentges/skyline0 reactions
- Sep 1, 2025[npm dependencies]: Bump next-safe-action from 7.10.8 to 8.0.11 in /src — Smegfi/papago0 reactions
- Sep 1, 2025chore(deps): bump next-safe-action from 8.0.8 to 8.0.11 — Shironex/portfolio0 reactions · 1 comment
- Sep 1, 2025chore: bump the dependencies group with 20 updates — alex289/NextJs-Boilerplate0 reactions · 2 comments
- Aug 25, 2025chore(deps): bump the all group across 1 directory with 94 updates — jaqubowsky/create-nextjs-app0 reactions · 1 comment
- Aug 23, 2025chore: bump the dependencies group with 19 updates — alex289/NextJs-Boilerplate0 reactions · 3 comments
- Aug 18, 2025[npm dependencies]: Bump next-safe-action from 7.10.8 to 8.0.10 in /src — Smegfi/papago0 reactions · 1 comment
- Aug 18, 2025chore(deps): bump the all group with 71 updates — jaqubowsky/create-nextjs-app0 reactions · 2 comments
- Aug 18, 2025chore(deps): bump next-safe-action from 8.0.8 to 8.0.10 — Shironex/portfolio0 reactions · 1 comment
- Aug 1, 2025chore(deps): bump next-safe-action from 8.0.2 to 8.0.8 — rifandani/ai-monorepo0 reactions · 1 comment
- Aug 1, 2025⬆️ Bump next-safe-action from 7.10.4 to 8.0.8 — quantified-uncertainty/squiggle0 reactions · 4 comments
- Jul 28, 2025[npm dependencies]: Bump next-safe-action from 7.10.8 to 8.0.8 in /src — Smegfi/papago0 reactions · 1 comment
- Jul 15, 2025chore(deps): bump next-safe-action from 7.10.4 to 8.0.8 — santosmarco/github-jtgc5e-20 reactions
- Jul 15, 2025Bump the dependencies group with 6 updates — RasengunShotaro/pdcxa0 reactions · 1 comment
- Jun 30, 2025[npm dependencies]: Bump next-safe-action from 7.10.8 to 8.0.7 in /src — Smegfi/papago0 reactions · 1 comment
- Jun 26, 2025Bump the dependencies group with 5 updates — RasengunShotaro/pdcxa0 reactions
- Jun 23, 2025[npm dependencies]: Bump next-safe-action from 7.10.8 to 8.0.4 in /src — Smegfi/papago0 reactions · 1 comment
- Jun 17, 2025chore(deps): bump next-safe-action from 7.10.4 to 8.0.3 — santosmarco/github-jtgc5e-20 reactions · 1 comment
- Jun 16, 2025Bump next-safe-action from 7.10.8 to 8.0.3 — joehentges/skyline0 reactions · 1 comment
- Jun 12, 2025[BUG] throwValidationErrors with overrideErrorMessage not working in v7.10.5 — next-safe-action/next-safe-action0 reactions · 1 comment
- Jun 9, 2025Bump next-safe-action from 7.10.8 to 8.0.2 — joehentges/skyline0 reactions · 1 comment
- Jun 9, 2025chore(deps): bump next-safe-action from 7.10.4 to 8.0.2 — santosmarco/github-jtgc5e-20 reactions · 1 comment
- Jun 9, 2025[npm dependencies]: Bump next-safe-action from 7.10.8 to 8.0.2 in /src — Smegfi/papago0 reactions · 1 comment
- Jun 4, 2025chore(deps): bump next-safe-action from 7.10.4 to 8.0.1 — santosmarco/github-jtgc5e-20 reactions · 1 comment
- Jun 3, 2025chore(deps): bump next-safe-action from 7.10.4 to 8.0.0 — santosmarco/github-jtgc5e-20 reactions · 1 comment
- Jun 3, 2025Bump the dependencies group with 5 updates — RasengunShotaro/pdcxa0 reactions · 1 comment
- Jun 2, 2025Bump next-safe-action from 7.10.8 to 8.0.0 — joehentges/skyline0 reactions · 1 comment
- May 13, 2025chore(deps): bump next-safe-action from 7.10.4 to 7.10.8 — santosmarco/github-jtgc5e-20 reactions · 1 comment
- May 1, 2025chore(deps): bump next-safe-action from 7.10.5 to 7.10.8 — rifandani/ai-monorepo0 reactions · 1 comment
- May 1, 2025⬆️ Bump next-safe-action from 7.10.4 to 7.10.8 — quantified-uncertainty/squiggle0 reactions · 3 comments
Used with
Projects with it also use organization-best-practices, tailwind-css-patterns and 8 more.
Other files people use alongside this one.
Files found in the same public projects as a version of this one, more often than they turn up anywhere else. Each project counts once, large collections count for less, and this file's own repository is left out.
lukevellaSkillorganization-best-practices
This skill provides guidance and enforcement rules for implementing multi-tenant organizations, teams, and role-based access control using Better Auth's organization plugin.
Also in 4 projects that use this
midudevSkilltailwind-css-patterns
Provides comprehensive Tailwind CSS utility-first styling patterns including responsive design, layout utilities, flexbox, grid, spacing, typography, colors, and modern CSS best practices. Use when styling React/Vue/Svelte components, building responsive layouts, implementing design systems, or optimizing CSS workflow.
Also in 5 projects that use this
lukevellaSkilltwo-factor-authentication-best-practices
This skill provides guidance and enforcement rules for implementing secure two-factor authentication (2FA) using Better Auth's twoFactor plugin.
Also in 3 projects that use this
xenitV1Skillnodejs-best-practices
Node.js development principles and decision-making. Framework selection, async patterns, security, and architecture. Teaches thinking, not copying.
Also in 5 projects that use this
nicepkgSkilltailwind-v4-shadcn
Production-tested setup for Tailwind CSS v4 with shadcn/ui, Vite, and React.
Also in 4 projects that use this
xfstudioSkillnodejs-backend-patterns
Build production-ready Node.js backend services with Express/Fastify, implementing middleware patterns, error handling, authentication, database integration, and API design best practices. Use when creating Node.js servers, REST APIs, GraphQL backends, or microservices architectures.
Also in 5 projects that use this
- +1 more from lukevella
Other versions22 projects use a version of this.
Word for word · 12
- midudev/preguntas-entrevista-react★ 7.8k100% same
- kokonut-labs/kokonutui★ 2.3k100% same
- vercel-labs/openreview★ 1.7k100% same
- subhadeeproy3902/mvpblocks★ 834100% same
- vercel-labs/workflow-workshop★ 6100% same
- john-data-chen/social-skill-ai-coach★ 4100% same
- LuanRoger/next-dx★ 1100% same
- patinaproject/skills★ 1100% same
- arkantrust/next-skills★ 0100% same
- davidanthonyn/claude-skills★ 0100% same
2 more not listed
Edited · 9
- openai/plugins★ 7.8k92% same
- legions-developer/invoicely★ 92399% same
- ever-co/ever-works★ 199100% same
- ever-works/ever-works★ 199100% same
- robotostudio/turbo-start-sanity★ 186100% same
- georgekhananaev/claude-skills-vault★ 3187% same
- LeonardoTrapani/better-skills★ 11100% same
- figueroaignacio/ignaciofigueroa.dev★ 7100% same
- zebbern/termstack★ 498% same
Wrote their own version · 1
- kimtth/agent-skill-100-lines-or-less★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository12 other files it gives its agents.
- AGENTS.mdAGENTS.md
- .agents/skills/vercel-react-best-practices/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- frontend-designSkill
- next-best-practicesSkill
- next-upgradeSkill
- pnpmSkill
- skill-creatorSkill
- tsdownSkill
- turborepoSkill
- vercel-react-best-practicesSkill
- vitestSkill
The file
We split this skill into the rules it gives an agent
2 rules. 2 are common, 0 are distinctive, and 0 are very specific to this project.
2
Common
Most of the 10 edited versions we read keep these.
0
Distinctive
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Common: line 190
Use when you need the cache refreshed within the same request:
- Common: line 205
Use for stale-while-revalidate behavior:
“Common” is measured: kept by at least 6 in 10 of the 10 edited versions of this file we could read. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Cache Components (Next.js 16+)
Cache Components enable Partial Prerendering (PPR) - mix static, cached, and dynamic content in a single route.
Enable Cache Components
// next.config.ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
cacheComponents: true,
}
export default nextConfigThis replaces the old experimental.ppr flag.
Three Content Types
With Cache Components enabled, content falls into three categories:
1. Static (Auto-Prerendered)
Synchronous code, imports, pure computations - prerendered at build time:
export default function Page() {
return (
<header>
<h1>Our Blog</h1> {/* Static - instant */}
<nav>...</nav>
</header>
)
}2. Cached (use cache)
Async data that doesn't need fresh fetches every request:
async function BlogPosts() {
'use cache'
cacheLife('hours')
const posts = await db.posts.findMany()
return <PostList posts={posts} />
}3. Dynamic (Suspense)
Runtime data that must be fresh - wrap in Suspense:
import { Suspense } from 'react'
export default function Page() {
return (
<>
<BlogPosts /> {/* Cached */}
<Suspense fallback={<p>Loading...</p>}>
<UserPreferences /> {/* Dynamic - streams in */}
</Suspense>
</>
)
}
async function UserPreferences() {
const theme = (await cookies()).get('theme')?.value
return <p>Theme: {theme}</p>
}use cache Directive
File Level
'use cache'
export default async function Page() {
// Entire page is cached
const data = await fetchData()
return <div>{data}</div>
}Component Level
export async function CachedComponent() {
'use cache'
const data = await fetchData()
return <div>{data}</div>
}Function Level
export async function getData() {
'use cache'
return db.query('SELECT * FROM posts')
}Cache Profiles
Built-in Profiles
'use cache' // Default: 5m stale, 15m revalidate'use cache: remote' // Platform-provided cache (Redis, KV)'use cache: private' // For compliance, allows runtime APIscacheLife() - Custom Lifetime
import { cacheLife } from 'next/cache'
async function getData() {
'use cache'
cacheLife('hours') // Built-in profile
return fetch('/api/data')
}Built-in profiles: 'default', 'minutes', 'hours', 'days', 'weeks', 'max'
Inline Configuration
async function getData() {
'use cache'
cacheLife({
stale: 3600, // 1 hour - serve stale while revalidating
revalidate: 7200, // 2 hours - background revalidation interval
expire: 86400, // 1 day - hard expiration
})
return fetch('/api/data')
}Cache Invalidation
cacheTag() - Tag Cached Content
import { cacheTag } from 'next/cache'
async function getProducts() {
'use cache'
cacheTag('products')
return db.products.findMany()
}
async function getProduct(id: string) {
'use cache'
cacheTag('products', `product-${id}`)
return db.products.findUnique({ where: { id } })
}updateTag() - Immediate Invalidation
Use when you need the cache refreshed within the same request:
'use server'
import { updateTag } from 'next/cache'
export async function updateProduct(id: string, data: FormData) {
await db.products.update({ where: { id }, data })
updateTag(`product-${id}`) // Immediate - same request sees fresh data
}revalidateTag() - Background Revalidation
Use for stale-while-revalidate behavior:
'use server'
import { revalidateTag } from 'next/cache'
export async function createPost(data: FormData) {
await db.posts.create({ data })
revalidateTag('posts') // Background - next request sees fresh data
}Runtime Data Constraint
Cannot access cookies(), headers(), or searchParams inside use cache.
Solution: Pass as Arguments
// Wrong - runtime API inside use cache
async function CachedProfile() {
'use cache'
const session = (await cookies()).get('session')?.value // Error!
return <div>{session}</div>
}
// Correct - extract outside, pass as argument
async function ProfilePage() {
const session = (await cookies()).get('session')?.value
return <CachedProfile sessionId={session} />
}
async function CachedProfile({ sessionId }: { sessionId: string }) {
'use cache'
// sessionId becomes part of cache key automatically
const data = await fetchUserData(sessionId)
return <div>{data.name}</div>
}Exception: use cache: private
For compliance requirements when you can't refactor:
async function getData() {
'use cache: private'
const session = (await cookies()).get('session')?.value // Allowed
return fetchData(session)
}Cache Key Generation
Cache keys are automatic based on:
- Build ID - invalidates all caches on deploy
- Function ID - hash of function location
- Serializable arguments - props become part of key
- Closure variables - outer scope values included
async function Component({ userId }: { userId: string }) {
const getData = async (filter: string) => {
'use cache'
// Cache key = userId (closure) + filter (argument)
return fetch(`/api/users/${userId}?filter=${filter}`)
}
return getData('active')
}Complete Example
import { Suspense } from 'react'
import { cookies } from 'next/headers'
import { cacheLife, cacheTag } from 'next/cache'
export default function DashboardPage() {
return (
<>
{/* Static shell - instant from CDN */}
<header><h1>Dashboard</h1></header>
<nav>...</nav>
{/* Cached - fast, revalidates hourly */}
<Stats />
{/* Dynamic - streams in with fresh data */}
<Suspense fallback={<NotificationsSkeleton />}>
<Notifications />
</Suspense>
</>
)
}
async function Stats() {
'use cache'
cacheLife('hours')
cacheTag('dashboard-stats')
const stats = await db.stats.aggregate()
return <StatsDisplay stats={stats} />
}
async function Notifications() {
const userId = (await cookies()).get('userId')?.value
const notifications = await db.notifications.findMany({
where: { userId, read: false }
})
return <NotificationList items={notifications} />
}Migration from Previous Versions
| Old Config | Replacement |
experimental.ppr | cacheComponents: true |
dynamic = 'force-dynamic' | Remove (default behavior) |
dynamic = 'force-static' | 'use cache' + cacheLife('max') |
revalidate = N | cacheLife({ revalidate: N }) |
unstable_cache() | 'use cache' directive |
Migrating unstable_cache to use cache
unstable_cache has been replaced by the use cache directive in Next.js 16. When cacheComponents is enabled, convert unstable_cache calls to use cache functions:
Before (unstable_cache):
import { unstable_cache } from 'next/cache'
const getCachedUser = unstable_cache(
async (id) => getUser(id),
['my-app-user'],
{
tags: ['users'],
revalidate: 60,
}
)
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params
const user = await getCachedUser(id)
return <div>{user.name}</div>
}After (use cache):
import { cacheLife, cacheTag } from 'next/cache'
async function getCachedUser(id: string) {
'use cache'
cacheTag('users')
cacheLife({ revalidate: 60 })
return getUser(id)
}
export default async function Page({ params }: { params: Promise<{ id: string }> }) {
const { id } = await params
const user = await getCachedUser(id)
return <div>{user.name}</div>
}Key differences:
- No manual cache keys -
use cachegenerates keys automatically from function arguments and closures. ThekeyPartsarray fromunstable_cacheis no longer needed. - Tags - Replace
options.tagswithcacheTag()calls inside the function. - Revalidation - Replace
options.revalidatewithcacheLife({ revalidate: N })or a built-in profile likecacheLife('minutes'). - Dynamic data -
unstable_cachedid not supportcookies()orheaders()inside the callback. The same restriction applies touse cache, but you can use'use cache: private'if needed.
Limitations
- Edge runtime not supported - requires Node.js
- Static export not supported - needs server
- Non-deterministic values (
Math.random(),Date.now()) execute once at build time insideuse cache
For request-time randomness outside cache:
import { connection } from 'next/server'
async function DynamicContent() {
await connection() // Defer to request time
const id = crypto.randomUUID() // Different per request
return <div>{id}</div>
}Sources:
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
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.

