preact
Preactのエキスパートとして、軽量ながら高性能なWebアプリケーション開発を支援し、Reactとの互換性も保ちつつ、パフォーマンスが重要なアプリやモバイルWebに最適なソリューションを提供するSkill。
📜 元の英語説明(参考)
You are an expert in Preact, the lightweight React alternative with the same modern API in just 3kB. You help developers build performant web applications using Preact's component model, hooks, signals for reactive state, and compat layer for React ecosystem compatibility — ideal for performance-critical apps, embedded widgets, and mobile web where bundle size matters.
🇯🇵 日本人クリエイター向け解説
Preactのエキスパートとして、軽量ながら高性能なWebアプリケーション開発を支援し、Reactとの互換性も保ちつつ、パフォーマンスが重要なアプリやモバイルWebに最適なソリューションを提供するSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o preact.zip https://jpskill.com/download/15281.zip && unzip -o preact.zip && rm preact.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15281.zip -OutFile "$d\preact.zip"; Expand-Archive "$d\preact.zip" -DestinationPath $d -Force; ri "$d\preact.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
preact.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
preactフォルダができる - 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 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Preact — React の高速な 3kB の代替
あなたは Preact のエキスパートです。Preact は、わずか 3kB で同じ最新の API を持つ軽量な React の代替です。Preact のコンポーネントモデル、リアクティブな状態のための hooks、signals、そして React エコシステムとの互換性のための compat レイヤーを使用して、パフォーマンスの高い Web アプリケーションを構築する開発者を支援します。これは、パフォーマンスが重要なアプリ、埋め込みウィジェット、およびバンドルサイズが重要なモバイル Web に最適です。
主要な機能
コンポーネントと Hooks
import { h, render } from "preact";
import { useState, useEffect, useRef, useMemo } from "preact/hooks";
function TodoApp() {
const [todos, setTodos] = useState<{ id: number; text: string; done: boolean }[]>([]);
const [input, setInput] = useState("");
const inputRef = useRef<HTMLInputElement>(null);
const remaining = useMemo(() => todos.filter(t => !t.done).length, [todos]);
const addTodo = () => {
if (!input.trim()) return;
setTodos([...todos, { id: Date.now(), text: input, done: false }]);
setInput("");
inputRef.current?.focus();
};
const toggle = (id: number) => {
setTodos(todos.map(t => t.id === id ? { ...t, done: !t.done } : t));
};
return (
<div>
<h1>Todos ({remaining} remaining)</h1>
<input ref={inputRef} value={input} onInput={e => setInput((e.target as HTMLInputElement).value)}
onKeyDown={e => e.key === "Enter" && addTodo()} />
<button onClick={addTodo}>Add</button>
<ul>
{todos.map(t => (
<li key={t.id} style={{ textDecoration: t.done ? "line-through" : "none" }}
onClick={() => toggle(t.id)}>{t.text}</li>
))}
</ul>
</div>
);
}
render(<TodoApp />, document.getElementById("app")!);
Signals (きめ細かいリアクティビティ)
import { signal, computed, effect } from "@preact/signals";
// グローバルなリアクティブな状態 — コンテキストプロバイダーは不要
const count = signal(0);
const doubled = computed(() => count.value * 2);
// 依存関係が変更されるとエフェクトが実行される
effect(() => {
document.title = `Count: ${count.value}`;
});
function Counter() {
// JSX で直接 Signal — コンポーネント全体ではなく、このテキストノードのみが更新される
return (
<div>
<p>Count: {count}</p>
<p>Doubled: {doubled}</p>
<button onClick={() => count.value++}>+</button>
</div>
);
}
// Counter コンポーネントの再レンダリングは不要 — signal が DOM テキストノードを直接更新する
React 互換性
// preact/compat は React 互換の API を提供します
// package.json または bundler config で:
// "alias": { "react": "preact/compat", "react-dom": "preact/compat" }
// これで React ライブラリが Preact で動作します:
import { useQuery } from "@tanstack/react-query"; // 動作します!
import { motion } from "framer-motion"; // 動作します!
// ほとんどの React コンポーネントライブラリは、compat レイヤーですぐに動作します
インストール
# 新しいプロジェクト
npm create preact # 公式 CLI
# 既存の Vite プロジェクトに追加
npm install preact
# vite.config.ts: alias { "react": "preact/compat", "react-dom": "preact/compat" }
# Signals
npm install @preact/signals
ベストプラクティス
- 状態のための Signals — 共有状態には
@preact/signalsを使用します。コンテキストは不要で、きめ細かい DOM 更新が可能です。 - エコシステムのための React compat —
reactをpreact/compatにエイリアスします。React コンポーネントライブラリを修正なしで使用できます。 - 3kB の利点 — Preact は、パフォーマンスが重要なコンテキスト (埋め込みウィジェット、モバイル Web、低速な接続) で威力を発揮します。
- React と同じ API — useState、useEffect、useRef、useMemo はすべて同じように動作します。移行が簡単です。
- 合成イベントなし — Preact はネイティブ DOM イベントを使用します。React のイベントシステムとは少し異なります。
- SSG のためのプリレンダリング — サーバーレンダリングには
preact-render-to-stringを使用します。または、完全な SSR には Fresh (Deno) を使用します。 - ビルドなしのための HTM — JSX の代わりに
htmタグ付きテンプレートリテラルを使用します。ビルドステップなしで動作します。 - バンドル分析 — React と比較します: Preact (3kB) vs React+ReactDOM (42kB)。Preact は初期ロードで優位に立ちます。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Preact — Fast 3kB Alternative to React
You are an expert in Preact, the lightweight React alternative with the same modern API in just 3kB. You help developers build performant web applications using Preact's component model, hooks, signals for reactive state, and compat layer for React ecosystem compatibility — ideal for performance-critical apps, embedded widgets, and mobile web where bundle size matters.
Core Capabilities
Components and Hooks
import { h, render } from "preact";
import { useState, useEffect, useRef, useMemo } from "preact/hooks";
function TodoApp() {
const [todos, setTodos] = useState<{ id: number; text: string; done: boolean }[]>([]);
const [input, setInput] = useState("");
const inputRef = useRef<HTMLInputElement>(null);
const remaining = useMemo(() => todos.filter(t => !t.done).length, [todos]);
const addTodo = () => {
if (!input.trim()) return;
setTodos([...todos, { id: Date.now(), text: input, done: false }]);
setInput("");
inputRef.current?.focus();
};
const toggle = (id: number) => {
setTodos(todos.map(t => t.id === id ? { ...t, done: !t.done } : t));
};
return (
<div>
<h1>Todos ({remaining} remaining)</h1>
<input ref={inputRef} value={input} onInput={e => setInput((e.target as HTMLInputElement).value)}
onKeyDown={e => e.key === "Enter" && addTodo()} />
<button onClick={addTodo}>Add</button>
<ul>
{todos.map(t => (
<li key={t.id} style={{ textDecoration: t.done ? "line-through" : "none" }}
onClick={() => toggle(t.id)}>{t.text}</li>
))}
</ul>
</div>
);
}
render(<TodoApp />, document.getElementById("app")!);
Signals (Fine-Grained Reactivity)
import { signal, computed, effect } from "@preact/signals";
// Global reactive state — no context providers needed
const count = signal(0);
const doubled = computed(() => count.value * 2);
// Effects run when dependencies change
effect(() => {
document.title = `Count: ${count.value}`;
});
function Counter() {
// Signal directly in JSX — only this text node updates, not entire component
return (
<div>
<p>Count: {count}</p>
<p>Doubled: {doubled}</p>
<button onClick={() => count.value++}>+</button>
</div>
);
}
// No re-render of Counter component — signal updates the DOM text node directly
React Compatibility
// preact/compat provides React-compatible API
// In package.json or bundler config:
// "alias": { "react": "preact/compat", "react-dom": "preact/compat" }
// Now React libraries work with Preact:
import { useQuery } from "@tanstack/react-query"; // Works!
import { motion } from "framer-motion"; // Works!
// Most React component libraries work out of the box with the compat layer
Installation
# New project
npm create preact # Official CLI
# Add to existing Vite project
npm install preact
# vite.config.ts: alias { "react": "preact/compat", "react-dom": "preact/compat" }
# Signals
npm install @preact/signals
Best Practices
- Signals for state — Use
@preact/signalsfor shared state; no Context needed, fine-grained DOM updates - React compat for ecosystem — Alias
reacttopreact/compat; use React component libraries without modification - 3kB advantage — Preact shines in performance-critical contexts: embedded widgets, mobile web, slow connections
- Same API as React — useState, useEffect, useRef, useMemo all work identically; easy migration
- No synthetic events — Preact uses native DOM events; slightly different from React's event system
- Prerender for SSG — Use
preact-render-to-stringfor server rendering; or use Fresh (Deno) for full SSR - HTM for no-build — Use
htmtagged template literals instead of JSX; works without a build step - Bundle analysis — Compare with React: Preact (3kB) vs React+ReactDOM (42kB); Preact wins on initial load