Framework2M+/wkMIT

preact

Preact is a fast 3kB alternative to React with the same modern API. It provides the thinnest possible virtual DOM abstraction on top of the browser DOM, impleme

Installation

npm
npm install preact
yarn
yarn add preact
pnpm
pnpm add preact

Import

ESM
import { h } from 'preact';

Quick Example

usage
import { useState } from 'preact/hooks';

export default function Counter() {
  const [count, setCount] = useState(0);
  return (
    <button onClick={() => setCount(count + 1)}>
      Count: {count}
    </button>
  );
}

About preact

Preact is a fast 3kB alternative to React with the same modern API. It provides the thinnest possible virtual DOM abstraction on top of the browser DOM, implementing a battle-tested and predictable API that is functionally equivalent to React for the vast majority of use cases. Preact achieves its tiny size by focusing on the core React features that matter most — components, hooks, context, refs, and JSX — while relying on the browser platform for features React reimplements. The preact/compat module provides full API compatibility with React, allowing most React libraries and components to work with Preact without modification by aliasing react imports. Preact is particularly well-suited for performance-sensitive applications, embedded widgets, and projects where bundle size is critical. It supports both class components and functional components with hooks, and includes Preact Signals, a reactive state primitive that provides fine-grained updates without re-rendering entire component trees. Preact's development experience closely mirrors React's, making it easy for React developers to adopt.

Quick Facts

Packagepreact
CategoryFramework
Weekly Downloads2M+
LicenseMIT
Installnpm install preact

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.