Preact is a small virtual DOM library that mirrors modern React patterns—hooks, classes, and JSX—with optional compatibility for importing React ecosystem components
Overview
Preact is a JavaScript library for building user interfaces with components and a virtual DOM, aimed at keeping bundle size small while following familiar React APIs. Developers assemble trees of components, describe output with JSX or tagged templates, and call render() to mount or update the DOM with minimal operations.
The API supports ES6 classes, hooks, and functional components. A preact/compat alias layer lets many React components and libraries run in Preact projects. The stack includes JSX, devtools hooks, hot module replacement, server-side rendering, and hydration from rendered HTML.
The diff layer is tuned for predictable updates and can run directly in the browser without transpilation in some setups. Asynchronous rendering uses a pluggable scheduler. Event handling registers native handlers and is intended to cooperate with other libraries on the same page.
Because of its size, Preact can embed in widgets or partial page areas as well as full applications. Shared components from the wider React ecosystem are reachable when compat is configured in the bundler.
Key features
- Small virtual DOM footprint
- Hooks and class components
- preact/compat React ecosystem bridge
- JSX and SSR with hydration
- DevTools and HMR support
- Pluggable async scheduler
- Browser-native event handlers
Use cases
- Embedded UI widgets
- React-like apps with smaller bundles
- Migrating from React via compat
- Server-rendered component pages