Hyperapp

1kB-ish JavaScript framework for building hypertext applications.

README

Hyperapp


The tiny framework for building hypertext applications.


- Do more with less—We have minimized the concepts you need to learn to get stuff done. Views, actions, effects, and subscriptions are all pretty easy to get to grips with and work together seamlessly.
- Write what, not how—With a declarative API that's easy to read and fun to write, Hyperapp is the best way to build purely functional, feature-rich, browser-based apps using idiomatic JavaScript.
- Smaller than a favicon—1 kB, give or take. Hyperapp is an ultra-lightweight Virtual DOM, highly-optimized diff algorithm, and state management library obsessed with minimalism.

Here's the first example to get you started. Try it here—no build step required!


  1. ``` html
  2. <script type="module">
  3.   import { h, text, app } from "https://unpkg.com/hyperapp"
  4.   const AddTodo = (state) => ({
  5.     ...state,
  6.     value: "",
  7.     todos: state.todos.concat(state.value),
  8.   })
  9.   const NewValue = (state, event) => ({
  10.     ...state,
  11.     value: event.target.value,
  12.   })
  13.   app({
  14.     init: { todos: [], value: "" },
  15.     view: ({ todos, value }) =>
  16.       h("main", {}, [
  17.         h("h1", {}, text("To do list")),
  18.         h("input", { type: "text", oninput: NewValue, value }),
  19.         h("ul", {},
  20.           todos.map((todo) => h("li", {}, text(todo)))
  21.         ),
  22.         h("button", { onclick: AddTodo }, text("New!")),
  23.       ]),
  24.     node: document.getElementById("app"),
  25.   })
  26. </script>
  27. <main id="app"></main>
  28. ```


The app starts by setting the initial state and rendering the view on the page. User input flows into actions, whose function is to update the state, causing Hyperapp to re-render the view.

When describing how a page looks in Hyperapp, we don't write markup. Instead, we use h() and text() to create a lightweight representation of the DOM (or virtual DOM for short), and Hyperapp takes care of updating the real DOM efficiently.

Installation


  1. ```console
  2. npm install hyperapp
  3. ```

Documentation


Learn the basics in the Tutorial, check out the Examples, or visit the Reference.

Packages


Official packages provide access to Web Platform APIs in a way that makes sense for Hyperapp. For third-party packages and real-world examples, browse the Hyperawesome collection.

PackageStatusAbout
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
[`@hyperapp/dom`](/packages/dom)[![npm](https://img.shields.io/npm/v/@hyperapp/dom.svg?style=for-the-badge&color=0366d6&label=)](https://www.npmjs.com/package/@hyperapp/dom)Inspect
[`@hyperapp/svg`](/packages/svg)[![npm](https://img.shields.io/npm/v/@hyperapp/svg.svg?style=for-the-badge&color=0366d6&label=)](https://www.npmjs.com/package/@hyperapp/svg)Draw
[`@hyperapp/html`](/packages/html)[![npm](https://img.shields.io/npm/v/@hyperapp/html.svg?style=for-the-badge&color=0366d6&label=)](https://www.npmjs.com/package/@hyperapp/html)Write
[`@hyperapp/time`](/packages/time)[![npm](https://img.shields.io/npm/v/@hyperapp/time.svg?style=for-the-badge&color=0366d6&label=)](https://www.npmjs.com/package/@hyperapp/time)Subscribe
[`@hyperapp/events`](/packages/events)[![npm](https://img.shields.io/npm/v/@hyperapp/events.svg?style=for-the-badge&color=0366d6&label=)](https://www.npmjs.com/package/@hyperapp/events)Subscribe
[`@hyperapp/http`](/packages/http)[![npm](https://img.shields.io/badge/-planned-6a737d?style=for-the-badge&label=)](https://www.npmjs.com/package/@hyperapp/http)Talk
[`@hyperapp/random`](/packages/random)[![npm](https://img.shields.io/badge/-planned-6a737d?style=for-the-badge&label=)](https://www.npmjs.com/package/@hyperapp/random)Declarative
[`@hyperapp/navigation`](/packages/navigation)[![npm](https://img.shields.io/badge/-planned-6a737d?style=for-the-badge&label=)](https://www.npmjs.com/package/@hyperapp/navigation)Subscribe

Need to create your own effects and subscriptions? You can do that too.


Help, I'm stuck!


If you've hit a stumbling block, hop on our Discord server to get help, and if you remain stuck, please file an issue, and we'll help you figure it out.

Contributing


Hyperapp is free and open-source software. If you want to support Hyperapp, becoming a contributor or sponsoring is the best way to give back. Thank you to everyone who already contributed to Hyperapp! <3
undefined

License