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 install preact
yarn add preact
pnpm add preact
Import
import { h } from 'preact';Quick Example
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
| Package | preact |
| Category | Framework |
| Weekly Downloads | 2M+ |
| License | MIT |
| Install | npm install preact |
Related Packages
React is the most popular JavaScript library for building user interfaces, developed and maintained …
React DOM is the package that provides DOM-specific methods for React, serving as the entry point to…
Svelte is a radical new approach to building user interfaces that shifts the work of the framework f…
Solid is a declarative JavaScript library for creating user interfaces that compiles templates to re…
Vue.js is a progressive JavaScript framework for building user interfaces, created by Evan You in 20…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.