preact
Installation
Review the source and dependencies with a prompt. A package is available to download.
Install with an AI assistant
Copy the prompt so your assistant can review the pinned revision and dependencies first.
View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "preact" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-582b883e931f82fe2d4936000785ece0f536b3b6f3564a66b3c50209121b76df. Verify the upstream source and version against https://github.com/TerminalSkills/skills before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.
Source and setup
github.com
Setup guidance pending
See the original source for supported tools, dependencies, and permissions.
Installation test pending
A Preact expert description: Preact is a lightweight (≈3 kB) React alternative that preserves modern APIs. It helps developers use its component model, hooks, reactive state signals, and compat layer to build high-performance web apps, especially for performance-sensitive, embedded components and size-constrained mobile web scenarios.
Introduction source: third_party · TerminalSkills · 1.0.0 Reference
SkillPi interpretation
- Testing
- Not tested
Browse files
Frontmatter
name: preact
description: >-
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.
license: Apache-2.0
compatibility: ''
metadata:
author: terminal-skills
version: 1.0.0
category: Frontend Development
tags:
- react-alternative
- lightweight
- fast
- jsx
- signals
- 3kbPreact — 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
Current listing version
1.0.0
Safety and assessment details
Quality assessment
Out of 100 · Assessment report from SkillPi LAB.
Highlights
- 提供 Preact 框架的专业支持,涵盖组件模型、hooks、signals 响应式状态、React 兼容层等核心能力
- 适用于性能敏感、嵌入式组件、移动端等高频刚需场景,具有明确实用价值
Highlights
- description 清晰描述 Preact 专家角色,覆盖轻量级 React 替代、3kB 大小、现代 API、性能优化等关键触发点
- 触发词边界清晰,用户能准确理解 Skill 适用范围
Highlights
- 文档结构完整,包含核心能力、代码示例、安装指南、最佳实践等章节
- frontmatter 完整,单文件未超限,符合规范要求
Highlights
- 提供完整代码示例(TodoApp、Signals、React Compat),工具来源明确
- 参数正确,覆盖主要使用场景,执行流程可靠
The arithmetic mean of the first four original scores, rounded to a whole number.
Static text checks
100 / 100 · skillpi-20261123-no-r3-v1
No current rules matched the text.
This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.
Permissions and checks before use
Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.
-
Install or fetch external dependencies
Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.
Mentioned in main document · lines 123, 127
Security rating and access scope
safe · Static evidence review; not a runtime safety guarantee.
Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.
User discussion
No verified reviews yet.