Preact is a 3KB alternative to React with the same modern API. It's the fastest way to build interactive web apps when bundle size matters.
Why Preact Over React
An e-commerce site had a React bundle of 140KB affecting their Core Web Vitals score. They switched to Preact — same components, same hooks — and the bundle dropped to 45KB. LCP improved by 1.2 seconds.
Key Features:
- 3KB gzipped — Smallest React-compatible library
- React Compatible — Drop-in replacement via preact/compat
- Hooks Support — useState, useEffect, useContext, and all standard hooks
- Signals — Built-in fine-grained reactivity
- Fast — Minimal overhead, direct DOM manipulation
Quick Start
npm init preact
Same as React
import { useState } from "preact/hooks"
function Counter() {
const [count, setCount] = useState(0)
return <button onClick={() => setCount(c => c + 1)}>Count: {count}</button>
}
Signals (Unique to Preact)
import { signal, computed } from "@preact/signals"
const count = signal(0)
const doubled = computed(() => count.value * 2)
function Counter() {
return (
<div>
<button onClick={() => count.value++}>{count}</button>
<p>Doubled: {doubled}</p>
</div>
)
}
Why Choose Preact
- 95% smaller than React — better Core Web Vitals
- Same API — migrate existing React apps easily
- Signals — fine-grained reactivity without re-renders
Check out Preact docs to get started.
Need fast web solutions? Check out my Apify actors or email spinov001@gmail.com for custom solutions.
Top comments (0)