Build performance-focused websites where bundle size directly impacts load time and user experience.
Create embedded widgets that need to run on third-party sites without bloating the page.
Develop apps for users on slow network connections where every kilobyte of JavaScript matters.
Migrate React code to a leaner stack while keeping the same component and hooks patterns.
Preact is a lightweight JavaScript library for building user interfaces, designed as a minimal alternative to React. It offers the same core API as React, components, hooks, JSX syntax, and a virtual DOM, but in a package that weighs roughly 4 kilobytes when compressed, compared to React's much larger footprint. The goal is to give developers the familiar React programming model without the overhead, making it especially well-suited for performance-critical applications or contexts where bundle size matters. Preact works by maintaining a virtual DOM, an in-memory description of what the UI should look like, and then calculating the minimum number of real DOM changes needed whenever something updates. This diffing process is highly optimized. You write components the same way you would in React: as functions or classes that return JSX, using hooks like useState and useEffect for managing state and side effects. A compatibility layer called preact/compat allows most existing React libraries and code to run on Preact without modification, just by aliasing the import. Preact also supports server-side rendering, hot module replacement for development, and browser DevTools integration. You would reach for Preact when you need the React development experience but are building for an environment where JavaScript bundle size is a significant concern, for example, performance-focused websites, embedded widgets, or apps targeting slow network connections. It is also a natural choice if you are already comfortable with React but want a leaner dependency. The tech stack is JavaScript and TypeScript, running in any modern browser environment. It has no required build tool and works with standard module bundlers.
Generated 2026-05-18 · Model: sonnet-4-6 · Verify against the repo before relying on details.