nextjs-static-shells
БесплатноБез исполняемых скриптовНе проверенStatic-first Next.js 16 architecture patterns: cached shells with dynamic slots, provider islands, 'use cache' boundaries, and link preloading strategy. Use…
от joelhooks★ 69 звёзд на GitHubОб этом скилле
Static-First Next.js 16 Patterns
Build a static shell first, then cut small dynamic holes where personalization or request-specific behavior is required.
- Static shell = deterministic, cacheable, fast first paint
- Dynamic holes = isolated request/user behavior streamed with Suspense
- Client interactivity = provider islands, not global client sprawl
Route Architecture: Entry + Static + Slots
Pattern
- Entry component (server, request-aware)
- Reads params/search/auth/session/cookies
- Validates access, resolves IDs, prepares dynamic props
- Static renderer (server,
'use cache')- Renders deterministic layout/content
- Accepts dynamic UI as slot props (
ReactNode)
- Dynamic slots
- Injected from entry component
- Suspense-wrapped where rendered in static shell
Why This Works
- Static shell stays cacheable
- Dynamic behavior is explicit and narrow
- Streaming keeps UI responsive
- No accidental full-route dynamic bailout
import { Suspense, type ReactNode } from 'react';
type PageProps = { params: Promise<{ slug: string }> };
/** Request-aware server entry. */
export default async function PageEntry({ params }: PageProps) {
const { slug } = await params;
const staticData = await getStaticData(slug); // deterministic
const userData = await getUserData(); // request-dependent
const dynamicPanel = <PersonalizedPanel userData={userData} />;
return <PageStatic data={staticData} panel={dynamicPanel} />;
}
type PageStaticProps = {
data: StaticData;
panel?: ReactNode;
};
/** Cached static shell. Keep request-volatile reads out. */
async function PageStatic({ data, panel }: PageStaticProps) {
'use cache';
return (
<main>
<Hero data={data.hero} />
<Content data={data.content} />
<Suspense fallback={<PanelSkeleton />}>{panel}</Suspense>
</main>
);
}
Cache Components Setup & Mechanics
Enable
// next.config.ts
import type { NextConfig } from 'next'
const nextConfig: NextConfig = {
cacheComponents: true,
}
export default nextConfig
Replaces the old experimental.ppr flag.
Three Content Types
| Type | Characteristic | Example |
|---|---|---|
| Static | Synchronous, pure computation | <header><h1>Our Blog</h1></header> |
Cached ('use cache') |
Async but deterministic for given inputs | db.posts.findMany() with cacheLife('hours') |
| Dynamic (Suspense) | Runtime/request-specific, must be fresh | cookies(), user session, notifications |
'use cache' Scope Levels
// File level — entire module cached
'use cache'
export default async function Page() { /* ... */ }
// 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 with cacheLife()
import { cacheLife } from 'next/cache'
async function getData() {
'use cache'
cacheLife('hours') // Built-in: 'default' | 'minutes' | 'hours' | 'days' | 'weeks' | 'max'
return fetch('/api/data')
}
// Or inline config:
async function getDataCustom() {
'use cache'
cacheLife({
stale: 3600, // 1h — serve stale while revalidating
revalidate: 7200, // 2h — background revalidation interval
expire: 86400, // 1d — hard expiration
})
return fetch('/api/data')
}
Built-in profile shortcuts: 'use cache' alone → 5m stale / 15m revalidate. 'use cache: remote' → platform KV. 'use cache: private' → allows runtime APIs (compliance escape hatch).
Cache Invalidation
import { cacheTag } from 'next/cache'
async function getProduct(id: string) {
'use cache'
cacheTag('products', `product-${id}`)
return db.products.findUnique({ where: { id } })
}
updateTag() — immediate, same-request invalidation:
'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}`) // caller sees fresh data
}
revalidateTag() — background stale-while-revalidate:
'use server'
import { revalidateTag } from 'next/cache'
export async function createPost(data: FormData) {
await db.posts.create({ data })
revalidateTag('posts') // next request sees fresh data
}
Cache Key Generation (Automatic)
Keys derived from: build ID + function location hash + serializable arguments + closure variables. No manual keyParts like unstable_cache.
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')
}
What Cannot Live Inside `'use cache
Установить nextjs-static-shells в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл nextjs-static-shells?
Static-first Next.js 16 architecture patterns: cached shells with dynamic slots, provider islands, 'use cache' boundaries, and link preloading strategy. Use when building or refactoring Next.js routes to maximize static rendering, implementing 'use cache' with dynamic personalization, splitting entry vs static renderers, scoping client providers, or tuning prefetch behavior. Triggers on 'static shell', 'use cache pattern', 'dynamic slots', 'provider island', 'prefetch strategy', 'static first', 'cache boundary', 'route goes dynamic unexpectedly', or any Next.js architecture work involving mixed static/dynamic rendering.
Как установить скилл nextjs-static-shells?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл nextjs-static-shells запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic