Install
openclaw skills install @kens-agents/preact-docs-v10-29-7Documentation reference for Preact v10.29.7. Use to look up the correct syntax, hooks, components, and API behavior for Preact. Not a coding tutor — only a reference lookup. Example triggers: "How does useState() work in Preact?", "What props does render() accept?", "What's the difference between preact and preact/compat?"
openclaw skills install @kens-agents/preact-docs-v10-29-7Look up Preact v10.29.7 syntax, hooks, components, and API behavior from the official docs.
| User wants... | Do this |
|---|---|
| API reference (full surface) | Read api-reference from scripts/preact-reference.json |
| Hooks (useState, useEffect, etc.) | Read hooks from scripts/preact-reference.json |
| Components (Fragment, Context) | Read components from scripts/preact-reference.json |
| Context API | Read context from scripts/preact-reference.json |
| Forms guidance | Read forms from scripts/preact-reference.json |
| Debugging tools | Read debugging from scripts/preact-reference.json |
| Preact vs React differences | Read differences-to-react from scripts/preact-reference.json |
| Getting started | Read getting-started from scripts/preact-reference.json |
| Preact CLI | Read cli from scripts/preact-reference.json |
| Options/config | Read options from scripts/preact-reference.json |
className, JSX, or hooks), point them to React's Getting Started guide first before using this Preact reference.differences-to-react.md first when user mentions React or React-like behavior — this is the #1 source of agent mistakes when mental model is Reactscripts/preact-reference.json for Preact-specific answerspreact/compat requirement for React ecosystem libraries — don't assume they work with vanilla Preacth() function and JSX — both work but have different use casesThis skill provides read-only access to the official Preact v10.29.7 documentation. Use it to answer questions like:
useState() work in Preact?"render() accept?"preact and preact/compat?"useEffect?"Do not use this skill to teach Preact from scratch or to generate whole projects.
// In your code
const fs = require('fs');
const reference = JSON.parse(fs.readFileSync('{baseDir}/scripts/preact-reference.json', 'utf8'));
// Search for specific hook
const result = reference.find(item =>
item.category === "hooks" &&
item.slug.includes("hooks")
);
This is the most important page — read differences-to-react category thoroughly before answering any Preact/React compatibility questions.
Key differences:
children as prop, React uses props.childrenpreact/compatUse preact/compat (alias for react and react-dom) when:
Do NOT use preact/compat when:
category="api-reference" — complete API in one placecategory="hooks" — useState, useEffect, useContext, etc.category="differences-to-react" — critical for React devscategory="components" — Fragment, Context, etc.category="context" — Provider/Consumer patterncategory="forms" — controlled components, refscategory="debugging" — devtools, warningscategory="cli" — Preact CLI usagecategory="options" — configuration options| Topic | Category | Key exports |
|---|---|---|
| Core | api-reference | h(), render(), Component, Fragment |
| Hooks | hooks | useState, useEffect, useContext, useRef, useReducer, useMemo, useCallback |
| Components | components | Fragment, Portal, Suspense |
| Context | context | createContext, Provider, Consumer |
| Compat | differences-to-react | preact/compat alias for React ecosystem |
import { h, render } from 'preact';
import { useState, useEffect } from 'preact/hooks';
function Counter() {
const [count, setCount] = useState(0);
useEffect(() => {
console.log('Count changed:', count);
}, [count]);
return (
<div>
<p>Count: {count}</p>
<button onClick={() => setCount(count + 1)}>
Increment
</button>
</div>
);
}
render(<Counter />, document.getElementById('app'));
// Instead of: import React from 'react';
import { h, Component } from 'preact';
// Or use the compat layer:
import React from 'preact/compat';
import ReactDOM from 'preact/compat';
// Now you can use React Router, Redux, etc.
import { BrowserRouter } from 'react-router-dom';
import { createContext, useContext } from 'preact/hooks';
const ThemeContext = createContext('light');
function ThemedButton() {
const theme = useContext(ThemeContext);
return <button className={theme}>Themed</button>;
}
// Provider usage
<ThemeContext.Provider value="dark">
<ThemedButton />
</ThemeContext.Provider>
preact/compat — vanilla Preact won't work with most React ecosystem packagesh() — both work, but h() is the native Preact function; JSX compiles to h()children differently than React in some edge casescomponentWillMount, componentWillReceiveProps behave differently or are deprecatedpreact-render-to-string package, not React's SSR APIs| Feature | React | Preact |
|---|---|---|
| Bundle size | ~40KB | ~3KB |
| Synthetic events | Yes | No (native events) |
| Children handling | props.children | Passed as prop, different edge cases |
| createContext default | undefined | null |
| useEffect cleanup | Fires after paint | Fires before next effect |
| Fragment syntax | <></> | Same, but different internal representation |
| Error boundaries | Full support | Limited support |
{baseDir}/scripts/preact-reference.json — Complete Preact v10.29.7 documentation index (embedded in skill)differences-to-react category — Must-read for React developers