一键导入
state-management
State management decision tree — Zustand for client UI, nuqs for URL state, useState for local. Use when managing client-side state.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
State management decision tree — Zustand for client UI, nuqs for URL state, useState for local. Use when managing client-side state.
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
Design-token and theming conventions for the Starter — semantic CSS variables in theme.css, Tailwind v4 @theme registration in globals.css, dark mode, and the Figma token-sync flow. Use when extracting repeated design values, adding/editing tokens, theming, or syncing tokens from Figma.
API service layer with ky/apiClient and Next.js API routes with Zod validation. Use when creating services, API endpoints, or HTTP calls.
Project file organization, naming conventions, and import patterns. Use when creating new files, organizing code, or deciding where to place modules.
Conventions when no auth provider is bundled. Use when adding authentication or guarding routes.
React component patterns — server vs client components, styling with cn(), props interfaces. Use when creating UI or shared components.
Use before writing or referencing any stack library — fetches version-accurate docs via the context7 MCP server so call signatures, hooks, and APIs match what is installed. Invoke on first usage of any non-none slot library, on any non-trivial Next.js API, or when uncertain whether an API is current.
| name | state-management |
| description | State management decision tree — Zustand for client UI, nuqs for URL state, useState for local. Use when managing client-side state. |
| paths | src/lib/store/** |
| Data type | Tool | Example |
|---|---|---|
| Server data | Data-fetching lib | User list, product details |
| URL state | nuqs | Search filters, pagination, tabs |
| Client UI state | Zustand | Sidebar open, theme, modal state |
| Form state | Forms library | Login form, create product form |
| Local component state | useState | Toggle, dropdown open |
import { create } from 'zustand'
interface UIStore {
sidebarOpen: boolean
toggleSidebar: () => void
}
export const useUIStore = create<UIStore>((set) => ({
sidebarOpen: false,
toggleSidebar: () => set((state) => ({ sidebarOpen: !state.sidebarOpen })),
}))
'use client'
import { useQueryState } from 'nuqs'
export function SearchFilter() {
const [search, setSearch] = useQueryState('q', { defaultValue: '' })
return (
<input value={search} onChange={(e) => setSearch(e.target.value)} placeholder="Search..." />
)
}
The ui.store.ts delegates toasts to Sonner. Use it directly or via the store convenience methods:
import { toast } from 'sonner'
// Direct (preferred)
toast.error('Something went wrong')
toast.success('Saved!')
// Or via the store hook
const { toast: t } = useUIStore().ui.notification
t.error('Something went wrong')
src/lib/store/*.store.tsuseState + useEffect for server data — use the data-fetching skillsrc/lib/store/index.ts