Preact: React's Lightweight Alternative
What you'll learn: How Preact delivers a React-compatible experience in just 3KB, and when its tiny size makes it the right choice.
The Lightweight React Clone
Preact is like a travel-sized version of React that fits in your pocket. While React's core library is around 40KB (minified and gzipped), Preact achieves nearly identical functionality in just 3KB. It's not a framework competitor like Vue or Angular—it's specifically designed to mimic React's API while being dramatically smaller.
How Does Preact Stay So Small?
Preact maintains React compatibility through clever engineering choices:
- Minimal abstraction layers: Direct DOM manipulation where React adds indirection
- Smaller virtual DOM implementation: Optimized diffing with less overhead
- No synthetic event system: Uses native browser events directly
- Stripped legacy support: Focuses on modern browsers only
Think of React as a Swiss Army knife with 30 tools, while Preact is the same knife with the 5 tools you actually use daily.
When Bundle Size Justifies Switching
Consider Preact when:
- Mobile performance matters: Every kilobyte affects load time on slow networks
- Landing pages or marketing sites: Where initial bundle size directly impacts bounce rates
- Embedded widgets: When your React component lives inside someone else's page
- Progressive web apps: Where offline cache size matters
You can often use preact/compat (an additional 2KB) to maintain full React compatibility, including existing React libraries. That's still 5KB total versus 40KB.
The Trade-Off
Preact sacrifices some edge-case compatibility and React's newest experimental features for size. But for most applications using stable React patterns—component-based architecture, unidirectional data flow, virtual DOM reconciliation—the difference is invisible.
Key Takeaway: Preact proves that React's core concepts (declarative UI, components, virtual DOM) can be implemented in 3KB, making it ideal when bundle size directly impacts user experience or business metrics.