Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Preact | 35,074 | 5,761 | 3,394 | a day ago | 221 | July 09, 2023 | 248 | mit | JavaScript | |
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM. | ||||||||||
Marko | 12,813 | 944 | 240 | a day ago | 821 | July 18, 2023 | 55 | mit | JavaScript | |
A declarative, HTML-based language that makes building web apps fun | ||||||||||
Hyperhtml | 3,026 | 143 | 55 | 2 months ago | 233 | October 04, 2022 | 12 | isc | HTML | |
A Fast & Light Virtual DOM Alternative | ||||||||||
Morphdom | 2,813 | 269 | 152 | 5 months ago | 67 | January 31, 2023 | 42 | mit | JavaScript | |
Fast and lightweight DOM diffing/patching (no virtual DOM needed) | ||||||||||
Asm Dom | 2,695 | 7 | 5 | 7 months ago | 16 | August 16, 2020 | 126 | other | C++ | |
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications) | ||||||||||
Percy | 2,191 | 3 | 4 | 2 months ago | 24 | January 09, 2023 | 41 | apache-2.0 | Rust | |
Build frontend browser apps with Rust + WebAssembly. Supports server side rendering. | ||||||||||
Sauron | 1,816 | 2 | 9 | 13 days ago | 107 | August 28, 2023 | mit | Rust | ||
A versatile web framework and library for building client-side and server-side web applications | ||||||||||
Binding.scala | 1,580 | 12 | 3 days ago | 119 | December 25, 2019 | 48 | mit | Scala | ||
Reactive data-binding for Scala | ||||||||||
Simple Virtual Dom | 1,567 | 14 | 6 | 3 years ago | 11 | November 08, 2018 | 10 | mit | JavaScript | |
Basic virtual-dom algorithm | ||||||||||
Atomico | 1,003 | 8 | 72 | a month ago | 276 | August 20, 2023 | 13 | mit | JavaScript | |
Atomico a micro-library for creating webcomponents using only functions, hooks and virtual-dom. |
Fast 3kB alternative to React with the same modern API.
All the power of Virtual DOM components, without the overhead:
|
You can find some awesome libraries in the awesome-preact list 😎
Note: You don't need ES2015 to use Preact... but give it a try!
With Preact, you create user interfaces by assembling trees of components and elements. Components are functions or classes that return a description of what their tree should output. These descriptions are typically written in JSX (shown underneath), or HTM which leverages standard JavaScript Tagged Templates. Both syntaxes can express trees of elements with "props" (similar to HTML attributes) and children.
To get started using Preact, first look at the render() function. This function accepts a tree description and creates the structure described. Next, it appends this structure to a parent DOM element provided as the second argument. Future calls to render() will reuse the existing tree and update it in-place in the DOM. Internally, render() will calculate the difference from previous outputted structures in an attempt to perform as few DOM operations as possible.
import { h, render } from 'preact';
// Tells babel to use h for JSX. It's better to configure this globally.
// See https://babeljs.io/docs/en/babel-plugin-transform-react-jsx#usage
// In tsconfig you can specify this with the jsxFactory
/** @jsx h */
// create our tree and append it to document.body:
render(
<main>
<h1>Hello</h1>
</main>,
document.body
);
// update the tree in-place:
render(
<main>
<h1>Hello World!</h1>
</main>,
document.body
);
// ^ this second invocation of render(...) will use a single DOM call to update the text of the <h1>
Hooray! render() has taken our structure and output a User Interface! This approach demonstrates a simple case, but would be difficult to use as an application grows in complexity. Each change would be forced to calculate the difference between the current and updated structure for the entire application. Components can help here by dividing the User Interface into nested Components each can calculate their difference from their mounted point. Here's an example:
import { render, h } from 'preact';
import { useState } from 'preact/hooks';
/** @jsx h */
const App = () => {
const [input, setInput] = useState('');
return (
<div>
<p>Do you agree to the statement: "Preact is awesome"?</p>
<input value={input} onInput={e => setInput(e.target.value)} />
</div>
);
};
render(<App />, document.body);
Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]
Support us with a monthly donation and help us continue our activities. [Become a backer]
MIT