PROVIDER Β· the 3KB React-compatible alternative
Preact
Preact delivers React-compatible APIs in a 3KB runtime where JSX, Hooks, and the compat alias keep migration cheap, especially for size-sensitive mobile, embedded widget, and extension work.
Pros
Cons
Product Information
Detailed Notes
Overview
Preact was released by Jason Miller in 2015 as a roughly 3KB React-compatible library providing the same JSX, components, Hooks, and context APIs, replaceable in most cases through the preact/compat alias.
For Programming Languages & Frameworks work the value is React authoring in constrained environments, since mobile and low-end devices are bundle-sensitive where 3KB versus React's tens of kilobytes matters, and embedded widgets, third-party site components, and browser extensions all fit with smooth aliasing for existing React projects.
Note the boundaries, because complex ecosystem libraries depending on React internals may break under compat mode, DevTools and debugging trail React, community and material are smaller, and large applications still need the full React ecosystem making Preact a lightweight-scenario tool.
Core Strengths
- Only about 3KB suiting mobile and low-end devices
- APIs closely match React with preact/compat easing replacement
- Built-in Signals provide finer-grained reactive updates
- Suits embedded widgets, extensions, and multi-host scenarios
Product Ecosystem
Core API
h and render, components, Hooks such as useState, useEffect, and useContext, plus Suspense.
Compatibility layer
preact/compat provides React and ReactDOM equivalent aliases.
Ecosystem and tools
preact-cli, Vite plugins, Signals, and the WMR development environment.
Drawbacks
- Complex components relying on React internals may break
- DevTools and debugging trail React
- Noticeably smaller community and third-party material
- Large applications still need the full React ecosystem
Use Cases
- Lightweight mobile apps (β β β β β ) - 3KB advantage
- Widgets embedded in sites (β β β β β ) - Multi-host friendly
- Browser extensions (β β β β ) - Size-sensitive
- Large enterprise frontends (β β ) - Choose React
Pricing
| Plan | Price | Scope |
|---|---|---|
| Preact | $0 | MIT licensed, free |
| Ecosystem tools | $0 | Open source and free |
| Hosting | Platform billing | Static hosting |
Entirely free with a simple rule to use Preact when bundle size is a hard constraint such as mobile, embedded, or extension work, and React otherwise to avoid compatibility debugging.
FAQ
-
Can Preact fully replace React? Mostly yes through the preact/compat alias, verifying library by library for React internals.
-
Is it faster than React? The runtime is smaller and starts faster, while update performance depends on implementation and gaps are less dramatic than size differences.
-
Are Signals mandatory? No, they are an optional fine-grained reactivity layer with regular Hooks fully usable.
Code Examples
A counter component
import { render } from 'preact';
import { useState } from 'preact/hooks';
function Counter() {
const [n, setN] = useState(0);
return <button onClick={() => setN(n + 1)}>Clicked {n} times</button>;
}
render(<Counter />, document.getElementById('app'));
APIs match React in a roughly 3KB runtime suiting mobile and embedded scenarios.
Alias React to Preact
// vite.config.js
export default {
resolve: { alias: { react: 'preact/compat', 'react-dom': 'preact/compat' } },
};
Existing React projects migrate through aliases after verifying dependency compatibility.
Community & Resources
Communities and official channels
- Preact Site β Docs, tutorial, and REPL
- GitHub preactjs/preact β Source, issues, and releases
- Stack Overflow #preact β Compat layer and bundle answers
Learning resources and tools
- Preact Getting Started β Install and basics
- Awesome Preact β Components and tooling
- Preact Signals β Fine-grained reactivity