← Back to list

nextjs-client-cookie-pattern
by kensleDev
⭐ 0🍴 0📅 Jan 16, 2026
SKILL.md
name: nextjs-client-cookie-pattern
IMPORTANT: Keep description on ONE line for Claude Code compatibility
prettier-ignore
description: Client component onClick/form → Server Action → set cookie. 'use client' calls 'use server' action using cookies() from next/headers. allowed-tools: Read, Write, Edit, Glob, Grep, Bash
Next.js: Client → Server Cookie Pattern
Quick Start
Two files: Client component ('use client') + Server action ('use server')
// Button.tsx
'use client';
import { setTheme } from './actions';
export default function Button() {
return <button onClick={() => setTheme('dark')}>Enable Dark Mode</button>;
}
// actions.ts
'use server';
import { cookies } from 'next/headers';
export async function setTheme(theme: string) {
const cookieStore = await cookies();
cookieStore.set('theme', theme, { httpOnly: true, maxAge: 60*60*24*365 });
}
Reference Files
- patterns.md - Cookie patterns, form submission, redirect, reading cookies
Notes
- Server-side only:
cookies()only works in Server Actions/Components - Use document.cookie in client components to read
- Last verified: 2025-01-11
Score
Total Score
40/100
Based on repository quality metrics
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
Reviews
💬
Reviews coming soon