CodeVetter · Repo Unpack · Feature catalog
preactjs/preact
The primary user-facing surface is a library API for constructing and updating interfaces. Core provides components, DOM rendering, hydration, context, fragments, refs, and portals; addons provide hooks, React adapters, diagnostics, and test controls. Compiler-facing exports support both automatic JSX and precompiled HTML templates. The demo exposes a route-based playground for rendering scenarios and ecosystem integrations; it is documented as a debugging application.
- createElement and cloneElement normalize props and variadic children, extract keys, and extract refs for non-function element types; Fragment returns its children.
- Class components support setState, forceUpdate, derived state, mount/update callbacks, shouldComponentUpdate, and snapshot-before-update behavior.
- Hydration reuses matching existing DOM nodes, attaches function-valued props, reports missing-node mismatches through an option hook, and specially synchronizes textarea values.
- createContext provides Provider and Consumer interfaces, default values, and subscriptions that force consumer updates when the provider value changes.
- createPortal continues a VNode subtree in another DOM container; compat adds containerInfo to the returned node.
- preact/hooks implements useState/useReducer, passive and layout effects, refs, imperative handles, memoization, callbacks, context, debug values, error boundaries, and stable per-root IDs.
- React compatibility includes Children utilities, PureComponent, memo with a custom comparator, forwardRef, DOM lookup, unmounting, flushSync, and StrictMode as a Fragment alias.
- Compat supplies Suspense and lazy, use for promises or context, and useSyncExternalStore with separate server/hydration snapshots.
- Compat client adapters expose createRoot with render/unmount and hydrateRoot; server adapters expose string/static-markup and stream interfaces.
- The JSX runtime exports jsx, jsxs, jsxDEV, Fragment, jsxTemplate, jsxAttr, and jsxEscape; template helpers serialize attributes and escape dynamic children.
- Debug validates render containers, element types, refs, event-handler values, hook placement, excessive rerenders, and duplicate keys; devtools exposes an attachment bridge and custom hook names.
- The demo route table exposes Home, state-order, reorder, spiral, pythagoras, todo, fragments, profiler, key_bug, context, devtools, suspense, empty-fragment, people profiles, styled-components, Redux, MobX, textfields, reduxBug, suspense-router, nested-suspense, contenteditable, Zustand, and Redux Toolkit.
- The Todo demo supports text entry, addition, and removal; People Browser supports name/ID sorting, profile navigation, and delayed contact removal using an in-memory MobX store.