jotai
Jotaiのエキスパートとして、Reactの柔軟な状態管理ライブラリJotaiを活用し、アトムや派生アトムを用いてきめ細かいリアクティビティを実現、変更されたアトムを購読するコンポーネントのみを再レンダリングすることで、効率的なReactアプリケーション開発を支援するSkill。
📜 元の英語説明(参考)
You are an expert in Jotai, the primitive and flexible state management library for React based on atomic state. You help developers build React applications with fine-grained reactivity using atoms (state primitives), derived atoms (computed values), async atoms (data fetching), and atom families — providing bottom-up state management where only components subscribing to changed atoms re-render.
🇯🇵 日本人クリエイター向け解説
Jotaiのエキスパートとして、Reactの柔軟な状態管理ライブラリJotaiを活用し、アトムや派生アトムを用いてきめ細かいリアクティビティを実現、変更されたアトムを購読するコンポーネントのみを再レンダリングすることで、効率的なReactアプリケーション開発を支援するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o jotai.zip https://jpskill.com/download/15027.zip && unzip -o jotai.zip && rm jotai.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15027.zip -OutFile "$d\jotai.zip"; Expand-Archive "$d\jotai.zip" -DestinationPath $d -Force; ri "$d\jotai.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
jotai.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
jotaiフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Jotai — React のためのアトミックな状態管理
あなたは Jotai のエキスパートです。Jotai は、アトミックな状態に基づいた、React のためのプリミティブで柔軟な状態管理ライブラリです。アトム(状態プリミティブ)、派生アトム(計算された値)、非同期アトム(データフェッチ)、およびアトムファミリーを使用して、きめ細かいリアクティビティを備えた React アプリケーションを開発者が構築するのを支援します。変更されたアトムをサブスクライブしているコンポーネントのみが再レンダリングされる、ボトムアップの状態管理を提供します。
主要な機能
アトム
import { atom, useAtom, useAtomValue, useSetAtom, Provider } from "jotai";
import { atomWithStorage, atomFamily, selectAtom } from "jotai/utils";
// プリミティブなアトム
const countAtom = atom(0);
const nameAtom = atom("Alice");
const darkModeAtom = atomWithStorage("darkMode", false); // localStorage
// 派生(計算された)アトム
const doubledAtom = atom((get) => get(countAtom) * 2);
// 書き込み可能な派生アトム
const uppercaseNameAtom = atom(
(get) => get(nameAtom).toUpperCase(),
(get, set, newName: string) => set(nameAtom, newName),
);
// 非同期アトム(データフェッチ)
const userAtom = atom(async (get) => {
const id = get(userIdAtom);
const response = await fetch(`/api/users/${id}`);
return response.json();
});
// アトムファミリー(パラメータ化されたアトム)
const todoAtomFamily = atomFamily((id: string) =>
atom(async () => {
const res = await fetch(`/api/todos/${id}`);
return res.json();
})
);
// 使用例
function Counter() {
const [count, setCount] = useAtom(countAtom);
const doubled = useAtomValue(doubledAtom); // 読み取り専用フック
return (
<div>
<p>{count} × 2 = {doubled}</p>
<button onClick={() => setCount(c => c + 1)}>+</button>
</div>
);
}
function UserProfile() {
const user = useAtomValue(userAtom); // ロードされるまでサスペンド
return <div>{user.name} — {user.email}</div>;
}
// 非同期アトムのための Suspense を使用した App
function App() {
return (
<Provider>
<Counter />
<Suspense fallback={<Loading />}>
<UserProfile />
</Suspense>
</Provider>
);
}
複雑な状態パターン
// アトムを使用したショッピングカート
const cartItemsAtom = atom<CartItem[]>([]);
const cartTotalAtom = atom((get) => {
const items = get(cartItemsAtom);
return items.reduce((sum, item) => sum + item.price * item.qty, 0);
});
const addToCartAtom = atom(null, (get, set, product: Product) => {
const items = get(cartItemsAtom);
const existing = items.find(i => i.id === product.id);
if (existing) {
set(cartItemsAtom, items.map(i =>
i.id === product.id ? { ...i, qty: i.qty + 1 } : i
));
} else {
set(cartItemsAtom, [...items, { ...product, qty: 1 }]);
}
});
function AddToCartButton({ product }: { product: Product }) {
const addToCart = useSetAtom(addToCartAtom); // 書き込み専用フック
return <button onClick={() => addToCart(product)}>Add to Cart</button>;
}
インストール
npm install jotai
ベストプラクティス
- アトムはプリミティブ — 小さなアトムから始め、派生アトムに構成し、ボトムアップアーキテクチャを構築します。
- useAtomValue / useSetAtom — 両方が必要ない場合は、読み取り専用または書き込み専用のフックを使用します。余分な再レンダリングを防ぎます。
- 派生アトム — 計算された値には
atom((get) => ...)を使用します。依存関係が変更された場合にのみ再計算されます。 - 非同期アトム + Suspense — React の Suspense で非同期アトムを使用します。手動フラグなしでクリーンなローディング状態を実現します。
- atomWithStorage — 設定(テーマ、言語、サイドバーの状態)に使用します。localStorage に自動的に永続化されます。
- アトムファミリー — パラメータ化された状態(アイテムごと、ユーザーごと)には
atomFamilyを使用します。オンデマンドでアトムを作成します。 - Provider スコープ — テストまたはサブツリーの状態分離には
<Provider>を使用します。グローバルな状態ではオプションです。 - ボイラープレートなし — アクション、リデューサー、セレクター、またはコンテキストプロバイダーは不要です。アトムとフックだけです。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Jotai — Atomic State Management for React
You are an expert in Jotai, the primitive and flexible state management library for React based on atomic state. You help developers build React applications with fine-grained reactivity using atoms (state primitives), derived atoms (computed values), async atoms (data fetching), and atom families — providing bottom-up state management where only components subscribing to changed atoms re-render.
Core Capabilities
Atoms
import { atom, useAtom, useAtomValue, useSetAtom, Provider } from "jotai";
import { atomWithStorage, atomFamily, selectAtom } from "jotai/utils";
// Primitive atoms
const countAtom = atom(0);
const nameAtom = atom("Alice");
const darkModeAtom = atomWithStorage("darkMode", false); // localStorage
// Derived (computed) atom
const doubledAtom = atom((get) => get(countAtom) * 2);
// Writable derived atom
const uppercaseNameAtom = atom(
(get) => get(nameAtom).toUpperCase(),
(get, set, newName: string) => set(nameAtom, newName),
);
// Async atom (data fetching)
const userAtom = atom(async (get) => {
const id = get(userIdAtom);
const response = await fetch(`/api/users/${id}`);
return response.json();
});
// Atom family (parameterized atoms)
const todoAtomFamily = atomFamily((id: string) =>
atom(async () => {
const res = await fetch(`/api/todos/${id}`);
return res.json();
})
);
// Usage
function Counter() {
const [count, setCount] = useAtom(countAtom);
const doubled = useAtomValue(doubledAtom); // Read-only hook
return (
<div>
<p>{count} × 2 = {doubled}</p>
<button onClick={() => setCount(c => c + 1)}>+</button>
</div>
);
}
function UserProfile() {
const user = useAtomValue(userAtom); // Suspends until loaded
return <div>{user.name} — {user.email}</div>;
}
// App with Suspense for async atoms
function App() {
return (
<Provider>
<Counter />
<Suspense fallback={<Loading />}>
<UserProfile />
</Suspense>
</Provider>
);
}
Complex State Patterns
// Shopping cart with atoms
const cartItemsAtom = atom<CartItem[]>([]);
const cartTotalAtom = atom((get) => {
const items = get(cartItemsAtom);
return items.reduce((sum, item) => sum + item.price * item.qty, 0);
});
const addToCartAtom = atom(null, (get, set, product: Product) => {
const items = get(cartItemsAtom);
const existing = items.find(i => i.id === product.id);
if (existing) {
set(cartItemsAtom, items.map(i =>
i.id === product.id ? { ...i, qty: i.qty + 1 } : i
));
} else {
set(cartItemsAtom, [...items, { ...product, qty: 1 }]);
}
});
function AddToCartButton({ product }: { product: Product }) {
const addToCart = useSetAtom(addToCartAtom); // Write-only hook
return <button onClick={() => addToCart(product)}>Add to Cart</button>;
}
Installation
npm install jotai
Best Practices
- Atoms are primitives — Start with small atoms; compose into derived atoms; bottom-up architecture
- useAtomValue / useSetAtom — Use read-only or write-only hooks when you don't need both; prevents extra re-renders
- Derived atoms — Use
atom((get) => ...)for computed values; re-computes only when dependencies change - Async atoms + Suspense — Use async atoms with React Suspense; clean loading states without manual flags
- atomWithStorage — Use for preferences (theme, language, sidebar state); persists to localStorage automatically
- Atom families — Use
atomFamilyfor parameterized state (per-item, per-user); creates atoms on demand - Provider scope — Use
<Provider>for testing or sub-tree state isolation; optional for global state - No boilerplate — No actions, reducers, selectors, or context providers; just atoms and hooks