All Projects → preactjs → Preact

preactjs / Preact

Licence: mit
⚛️ Fast 3kB React alternative with the same modern API. Components & Virtual DOM.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
HTML
75241 projects

Projects that are alternatives of or similar to Preact

Val
VirtualDOM abstraction layer - give yourself better integration and full control over the DOM with any virtual DOM library that uses a Hyperscript-like API such as React and Preact.
Stars: ✭ 181 (-99.41%)
Mutual labels:  virtual-dom, vdom, components, dom, preact
Vhtml
Render JSX/Hyperscript to HTML strings, without VDOM 🌈
Stars: ✭ 556 (-98.18%)
Mutual labels:  virtual-dom, vdom, jsx, preact
Omi
Front End Cross-Frameworks Framework - 前端跨框架跨平台框架
Stars: ✭ 12,153 (-60.19%)
Mutual labels:  virtual-dom, vdom, jsx, preact
Redux React Starter
DEPRECATED use the new https://github.com/didierfranc/react-webpack-4
Stars: ✭ 137 (-99.55%)
Mutual labels:  virtual-dom, components, jsx, preact
Wonders
🌈 Declarative JavaScript framework to build command-line applications.
Stars: ✭ 34 (-99.89%)
Mutual labels:  virtual-dom, vdom, jsx
Hyperawesome
A curated list of awesome projects built with Hyperapp & more.
Stars: ✭ 446 (-98.54%)
Mutual labels:  vdom, dom, jsx
Ijk
Transforms arrays into virtual dom trees; a terse alternative to JSX and h
Stars: ✭ 452 (-98.52%)
Mutual labels:  vdom, dom, preact
Preact Render Spy
Render preact components with access to the produced virtual dom for testing.
Stars: ✭ 178 (-99.42%)
Mutual labels:  vdom, jsx, preact
Virtual Dom
关于Vue,React,Preact和Omi等框架源码的解读
Stars: ✭ 139 (-99.54%)
Mutual labels:  virtual-dom, jsx, preact
Nerv
A blazing fast React alternative, compatible with IE8 and React 16.
Stars: ✭ 5,409 (-82.28%)
Mutual labels:  vdom, jsx, preact
Preact Worker Demo
Demo of preact rendering an entire app in a Web Worker.
Stars: ✭ 204 (-99.33%)
Mutual labels:  virtual-dom, dom, preact
Asm Dom
A minimal WebAssembly virtual DOM to build C++ SPA (Single page applications)
Stars: ✭ 2,604 (-91.47%)
Mutual labels:  virtual-dom, vdom, dom
Preact Markup
⚡️ Render HTML5 as VDOM, with Components as Custom Elements!
Stars: ✭ 167 (-99.45%)
Mutual labels:  dom, jsx, preact
hsx
Static HTML sites with JSX and webpack (no React).
Stars: ✭ 15 (-99.95%)
Mutual labels:  components, dom, jsx
Ng Vdom
(Developer Preview) A virtual-DOM extension for Angular, also work as React bridge.
Stars: ✭ 249 (-99.18%)
Mutual labels:  virtual-dom, vdom, jsx
Muve
Muve is a micro library for building interactive javascript applications.
Stars: ✭ 11 (-99.96%)
Mutual labels:  virtual-dom, vdom, jsx
Preact Habitat
Zero configuration Preact widgets renderer in any host DOM
Stars: ✭ 444 (-98.55%)
Mutual labels:  vdom, preact
Ivi
🔥 Javascript (TypeScript) library for building web user interfaces
Stars: ✭ 445 (-98.54%)
Mutual labels:  virtual-dom, vdom
Vidom
Library to build UI based on virtual DOM
Stars: ✭ 408 (-98.66%)
Mutual labels:  virtual-dom, jsx
Etch
Builds components using a simple and explicit API around virtual-dom
Stars: ✭ 545 (-98.21%)
Mutual labels:  virtual-dom, components

Preact

Fast 3kB alternative to React with the same modern API.

All the power of Virtual DOM components, without the overhead:

  • Familiar React API & patterns: ES6 Class, hooks, and Functional Components
  • Extensive React compatibility via a simple preact/compat alias
  • Everything you need: JSX, VDOM, DevTools, HMR, SSR.
  • Highly optimized diff algorithm and seamless hydration from Server Side Rendering
  • Supports all modern browsers and IE11
  • Transparent asynchronous rendering with a pluggable scheduler
  • Instant production-grade app setup with Preact CLI

💁 More information at the Preact Website ➞

npm Preact Slack Community OpenCollective Backers OpenCollective Sponsors

coveralls gzip size brotli size

You can find some awesome libraries in the awesome-preact list 😎


Getting Started

💁 Note: You don't need ES2015 to use Preact... but give it a try!

The easiest way to get started with Preact is to use Preact CLI. This simple command-line tool wraps up the best possible tooling for you, and even keeps things like Webpack and Babel up-to-date as they change. Best of all, it's easy to understand! Start a project or compile for production in a single command (preact build), with no configuration needed and best practices baked in! 🙌

Tutorial: Building UI with Preact

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} onChange={e => setInput(e.target.value)} />
		</div>
	)
}

render(<App />, document.body);

Backers

Support us with a monthly donation and help us continue our activities. [Become a backer]

Sponsors

Become a sponsor and get your logo on our README on GitHub with a link to your site. [Become a sponsor]


License

MIT

Preact

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].