preact
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "preact":https://skillpi.com/zh/skills/deepskill-582b883e931f82fe2d4936000785ece0f536b3b6f3564a66b3c50209121b76df。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
Preact 专家说明,Preact 是大小约 3 kB 的轻量级 React 替代方案,保有现代 API。帮助开发者使用组件模型、钩子(hooks)、响应式状态信号(signals)与兼容层(compat layer)构建高性能 Web 应用,适合对性能和包体积敏感的应用、嵌入式组件与移动端场景。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 实测状态
- 未测试
文件浏览
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
当前收录版本
1.0.0
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Preact 框架的专业支持,涵盖组件模型、hooks、signals 响应式状态、React 兼容层等核心能力
- 适用于性能敏感、嵌入式组件、移动端等高频刚需场景,具有明确实用价值
亮点
- description 清晰描述 Preact 专家角色,覆盖轻量级 React 替代、3kB 大小、现代 API、性能优化等关键触发点
- 触发词边界清晰,用户能准确理解 Skill 适用范围
亮点
- 文档结构完整,包含核心能力、代码示例、安装指南、最佳实践等章节
- frontmatter 完整,单文件未超限,符合规范要求
亮点
- 提供完整代码示例(TodoApp、Signals、React Compat),工具来源明确
- 参数正确,覆盖主要使用场景,执行流程可靠
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 123, 127 行
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。