# inferno
**Repository Path**: mirrors/inferno
## Basic Information
- **Project Name**: inferno
- **Description**: :fire: An extremely fast, React-like JavaScript library for building modern user interfaces
- **Primary Language**: Unknown
- **License**: MIT
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 12
- **Forks**: 0
- **Created**: 2017-04-03
- **Last Updated**: 2025-08-30
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
[](https://github.com/infernojs/inferno/actions)
[](https://coveralls.io/github/infernojs/inferno?branch=master)
[](https://github.com/infernojs/inferno/blob/master/LICENSE.md)
[](https://www.npmjs.com/package/inferno)
[](https://www.npmjs.org/package/inferno)
[](https://discord.gg/SUKuhgaBpF)
[](https://unpkg.com/inferno/dist/inferno.min.js)
[](#backers) [](#sponsors)
Inferno is an insanely fast, React-like library for building high-performance user interfaces on both the client and server.
## Description
The main objective of the InfernoJS project is to provide the fastest possible **runtime** performance for web applications. Inferno excels at rendering real time data views or large DOM trees.
The performance is achieved through multiple optimizations, for example:
- Inferno's own JSX compilers creates monomorphic `createVNode` calls, instead of `createElement` calls.
Optimizing runtime performance of the application.
- [SWC plugin inferno](https://github.com/infernojs/swc-plugin-inferno) is a plugin for [SWC](https://swc.rs/). It can compile TSX and JSX
- [Babel plugin inferno](https://github.com/infernojs/babel-plugin-inferno) is a plugin for [BabelJs](https://babeljs.io/). It can compile JSX.
- [TS plugin inferno](https://github.com/infernojs/ts-plugin-inferno) is a plugin for [TSC](https://www.typescriptlang.org/). It can compile TSX.
- Inferno's diff process uses bitwise flags to memoize the shape of objects
- Child nodes are normalized only when needed
- Special JSX flags can be used during compile time to optimize runtime performance at application level
- Many micro optimizations
## Features
- Component driven + one-way data flow architecture
- React-like API, concepts and component lifecycle events
- Partial synthetic event system, normalizing events for better cross browser support
- Inferno's [`linkEvent`](https://github.com/infernojs/inferno/blob/master/README.md#linkevent-package-inferno) feature removes the need to use arrow functions or binding event callbacks
- Isomorphic rendering on both client and server with `inferno-server`
- Unlike React and Preact, Inferno has lifecycle events on functional components
- Unlike Preact and other React-like libraries, Inferno has controlled components for input/select/textarea elements
- Components can be rendered outside their current html hierarchy using `createPortal` - API
- Support for [older browsers](https://github.com/infernojs/inferno#browser-support) without any polyfills
- defaultHooks for Functional components, this way re-defining lifecycle events per usage can be avoided
- Inferno supports setting styles using string `` or using object literal syntax ``. For camelCase syntax support see [`inferno-compat`](https://github.com/infernojs/inferno/tree/master/packages/inferno-compat).
- Fragments (v6)
- createRef and forwardRef APIs (v6)
- componentDidAppear, componentWillDisappear and componentWillMove (v8) - class and function component callbacks to ease animation work, see [inferno-animation](https://github.com/infernojs/inferno/tree/master/packages/inferno-animation) package
## Runtime requirements
Inferno v9 requires following features to be present in the executing runtime:
- `Promise`
- `String.prototype.includes()`
- `String.prototype.startsWith()`
- `Array.prototype.includes()`
- `Object.spread()`
- `for ... of`
## Browser support
Since version 4 we have started running our test suite **without** any polyfills.
Inferno is now part of [Saucelabs](https://saucelabs.com/) open source program and we use their service for executing the tests.
InfernoJS is actively tested with browsers listed below, however it may run well on older browsers as well.
This is due to limited support of browser versions in recent testing frameworks. https://github.com/jasmine/jasmine/blob/main/release_notes/5.0.0.md
[](https://app.saucelabs.com/open_sauce/user/Havunen/tests/vdc)
## Migration guides
- [Inferno v4](https://github.com/infernojs/inferno/blob/master/documentation/v4-migration.md)
- [Inferno v6](https://github.com/infernojs/inferno/blob/master/documentation/v6-migration.md)
## Benchmarks
Live examples at [https://infernojs.github.io/inferno](https://infernojs.github.io/inferno)
- [UI Bench](https://localvoid.github.io/uibench/)
- [dbmonster](https://infernojs.github.io/inferno/dbmonster/)
- [JS Web Frameworks Benchmark (current)](https://krausest.github.io/js-framework-benchmark/current.html)
- [Isomorphic-UI-Benchmark](https://github.com/marko-js/isomorphic-ui-benchmarks)
- [1k Components](https://infernojs.github.io/inferno/1kcomponents/)
## Code Example
Let's start with some code. As you can see, Inferno intentionally keeps the same design ideas as React regarding components: one-way data flow and separation of concerns.
In these examples, JSX is used via the [Inferno JSX Babel Plugin](https://github.com/infernojs/babel-plugin-inferno) to provide a simple way to express Inferno virtual DOM. You do not need to use JSX, it's completely **optional**, you can use [hyperscript](https://github.com/infernojs/inferno/tree/master/packages/inferno-hyperscript) or [createElement](https://github.com/infernojs/inferno/tree/master/packages/inferno-create-element) (like React does).
Keep in mind that compile time optimizations are available only for JSX.
```jsx
import { render } from 'inferno';
const message = "Hello world";
render(
,
document.getElementById("app")
);
```
Furthermore, Inferno also uses ES6 components like React:
```jsx
import { render, Component } from 'inferno';
class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0
};
}
render() {
return (
Header!
Counter is at: { this.state.counter }
);
}
}
render(
,
document.getElementById("app")
);
```
Because performance is an important aspect of this library, we want to show you how to optimize your application even further.
In the example below we optimize diffing process by using JSX **$HasVNodeChildren** and **$HasTextChildren** to predefine children shape compile time.
In the MyComponent render method there is a div that contains JSX expression `node` as its content. Due to dynamic nature of Javascript
that variable `node` could be anything and Inferno needs to go through the normalization process to make sure there are no nested arrays or other invalid data.
Inferno offers a feature called ChildFlags for application developers to pre-define the shape of vNode's child node. In this example case
it is using `$HasVNodeChildren` to tell the JSX compiler, that this vNode contains only single element or component vNode.
Now inferno will not go into the normalization process runtime, but trusts the developer decision about the shape of the object and correctness of data.
If this contract is not kept and `node` variable contains invalid value for the pre-defined shape (fe. `null`), then application would crash runtime.
There is also span-element in the same render method, which content is set dynamically through `_getText()` method. There `$HasTextChildren` child-flag
fits nicely, because the content of that given "span" is never anything else than text.
All the available child flags are documented [here](https://infernojs.org/docs/guides/optimizations).
```jsx
import { createTextVNode, render, Component } from 'inferno';
class MyComponent extends Component {
constructor(props) {
super(props);
this.state = {
counter: 0
};
}
_getText() {
return 'Hello!';
}
render() {
const node = this.state.counter > 0 ?
0
: {this._getText()};
return (
Header!
{node}
);
}
}
render(
,
document.getElementById("app")
);
```
### Tear down
To tear down inferno application you need to render null on root element.
Rendering `null` will trigger unmount lifecycle hooks for whole vDOM tree and remove global event listeners.
It is important to unmount unused vNode trees to free browser memory.
```jsx
import { createTextVNode, render, Component } from 'inferno';
const rootElement = document.getElementById("app");
// Start the application
render(
,
rootElement
);
// Tear down
render(
null,
rootElement
);
```
### More Examples
If you have built something using Inferno you can add them here:
- [**Simple Clock** (@JSFiddle)](https://jsfiddle.net/4bha7kcg/)
- [**Simple JS Counter** (@github/scorsi)](https://github.com/scorsi/simple-counter-inferno-cerebral-fusebox): SSR Inferno (view) + Cerebral (state manager) + FuseBox (build system/bundler)
- [**Online interface to TMDb movie database** (@codesandbox.io)](https://codesandbox.io/s/9zjo5yx8po): Inferno + [Inferno hyperscript](https://github.com/infernojs/inferno) (view) + [Superagent](https://github.com/visionmedia/superagent) (network requests) + Web component ([custom elements v1](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements)) + [state-transducer](https://github.com/brucou/state-transducer)
(state machine library)
- [**Lemmy - a self-hostable reddit alternative** (front end in Inferno)](https://github.com/dessalines/lemmy)
## Getting Started
The easiest way to get started with Inferno is by using [Create Inferno App](https://github.com/infernojs/create-inferno-app).
Alternatively, you can try any of the following:
* the [Inferno Boilerplate](https://github.com/infernojs/inferno-boilerplate) for a very simple setup.
* for a more advanced example demonstrating how Inferno might be used, we recommend trying out [Inferno Starter Project](https://github.com/nightwolfz/inferno-starter) by [nightwolfz](https://github.com/nightwolfz/).
* for using Inferno to build a mobile app, try [Inferno Mobile Starter Project](https://github.com/Rudy-Zidan/inferno-mobile) by [Rudy-Zidan](https://github.com/Rudy-Zidan).
* for [TypeScript](https://www.typescriptlang.org/) support and bundling, check out [ts-plugin-inferno](https://github.com/infernojs/ts-plugin-inferno), or [inferno-typescript-example](https://github.com/infernojs/inferno-typescript-example).
* for an example of how to use Inferno in [codesandbox](https://codesandbox.io/): https://codesandbox.io/s/znmyj24w4p
* for using [parcel and typescript](https://github.com/jayy-lmao/inferno-parcel-ts)
Core package:
```sh
npm install --save inferno
```
Addons:
```sh
# server-side rendering
npm install --save inferno-server
# routing
npm install --save inferno-router
```
Pre-bundled files for browser consumption can be found on [our cdnjs](https://cdnjs.com/libraries/inferno):
Or on jsDelivr:
```
https://cdn.jsdelivr.net/npm/inferno@latest/dist/inferno.min.js
```
Or on unpkg.com:
```
https://unpkg.com/inferno@latest/dist/inferno.min.js
```
### Creating Virtual DOM
#### JSX:
```sh
npm install --save-dev babel-plugin-inferno
```
#### Hyperscript:
```sh
npm install --save inferno-hyperscript
```
#### createElement:
```sh
npm install --save inferno-create-element
```
### Compatibility with existing React apps
```sh
npm install --save-dev inferno-compat
```
Note: Make sure you read more about [`inferno-compat`](https://github.com/infernojs/inferno/tree/master/packages/inferno-compat) before using it.
## Third-party state libraries
Inferno now has bindings available for some of the major state management libraries out there:
- Redux via [`inferno-redux`](https://github.com/infernojs/inferno/tree/dev/packages/inferno-redux)
- MobX via [`inferno-mobx`](https://github.com/infernojs/inferno/tree/dev/packages/inferno-mobx)
- Cerebral via [`@cerebral/inferno`](https://github.com/cerebral/cerebral/tree/master/packages/node_modules/@cerebral/inferno)
## JSX
Inferno has its own [JSX Babel plugin](https://github.com/trueadm/babel-plugin-inferno).
## Differences from React
- Inferno doesn't have a fully synthetic event system like React does. Inferno has a partially synthetic event system, instead opting to only delegate certain events (such as `onClick`).
- Inferno doesn't support React Native. Inferno was only designed for the browser/server with the DOM in mind.
- Inferno doesn't support legacy string refs, use `createRef` or callback `ref` API
- Inferno provides lifecycle events on functional components. This is a major win for people who prefer lightweight components rather than ES2015 classes.
## Differences from Preact
- Inferno has a partial synthetic event system, resulting in better performance via delegation of certain events.
- Inferno is *much* faster than Preact in rendering, updating and removing elements from the DOM. Inferno diffs against virtual DOM, rather than the real DOM (except when loading from server-side rendered content), which means it can make drastic improvements. Unfortunately, diffing against the real DOM has a 30-40% overhead cost in operations.
- Inferno fully supports controlled components for `input`/`select`/`textarea` elements. This prevents lots of edgecases where the virtual DOM is not the source of truth (it should always be). Preact pushes the source of truth to the DOM itself.
- Inferno provides lifecycle events on functional components. This is a major win for people who prefer lightweight components rather than ES2015 classes.
## Event System
Like React, Inferno also uses a light-weight synthetic event system in certain places (although both event systems differ massively). Inferno's event system provides highly efficient delegation and an event helper called [`linkEvent`](https://github.com/infernojs/inferno/blob/master/README.md#linkevent-package-inferno).
One major difference between Inferno and React is that Inferno does not rename events or change how they work by default. Inferno only specifies that events should be camel cased, rather than lower case. Lower case events will bypass
Inferno's event system in favour of using the native event system supplied by the browser. For example, when detecting changes on an `` element, in React you'd use `onChange`, with Inferno you'd use `onInput` instead (the
native DOM event is `oninput`).
Available synthetic events are:
- `onClick`
- `onDblClick`
- `onFocusIn`
- `onFocusOut`
- `onKeyDown`
- `onKeyPress`
- `onKeyUp`
- `onMouseDown`
- `onMouseMove`
- `onMouseUp`
- `onTouchEnd`
- `onTouchMove`
- `onTouchStart`
### `linkEvent` (package: `inferno`)
`linkEvent()` is a helper function that allows attachment of `props`/`state`/`context` or other data to events without needing to `bind()` them or use arrow functions/closures. This is extremely useful when dealing with events in functional components. Below is an example:
```jsx
import { linkEvent } from 'inferno';
function handleClick(props, event) {
props.validateValue(event.target.value);
}
function MyComponent(props) {
return
;
}
```
This is an example of using it with ES2015 classes:
```jsx
import { linkEvent, Component } from 'inferno';
function handleClick(instance, event) {
instance.setState({ data: event.target.value });
}
class MyComponent extends Component {
render () {
return
;
}
}
```
`linkEvent()` offers better performance than binding an event in a class constructor and using arrow functions, so use it where possible.
## Controlled Components
In HTML, form elements such as ``, `