Mode:
Duration:
1
Coding works best on desktop or with an external keyboard.
Coding works best on desktop or with an external keyboard.
Basic counter with increment, decrement, reset, and theme toggle.
import { h, app } from 'https://unpkg.com/hyperapp?module';
const state = { count: 0, isDark: false };
const actions = {
increment: () => s => ({ count: s.count + 1 }),
decrement: () => s => ({ count: s.count - 1 }),
reset: () => s => ({ count: 0 }),
toggleTheme: () => s => ({ isDark: !s.isDark })
};
const view = (s, a) => (
h('div', { class: s.isDark ? 'dark-theme' : 'light-theme' }, [
h('h2', {}, 'Counter: ' + s.count),
h('div', {}, [
h('button', { onclick: a.increment }, '+'),
h('button', { onclick: a.decrement }, '-'),
h('button', { onclick: a.reset }, 'Reset')
]),
h('button', { onclick: a.toggleTheme }, 'Switch to ' + (s.isDark ? 'Light' : 'Dark') + ' Theme')
])
);
app({ init: state, view, node: document.body, actions });Hyperapp is an ultra-lightweight (≈1 KB), functional JavaScript library for building user interfaces using a minimalist architecture of state, actions, and a virtual DOM. It emphasizes simplicity, purity, and predictable UI updates.
Origin & Creator
Created by Jorge Bucaran in 2017 as a tiny yet expressive alternative to React and Elm, designed to be minimal and functional.
Industrial Note
Hyperapp is specialized for teams that want extremely small bundles, functional UI patterns, and codebases with minimal abstraction - perfect for microtools, PWAs, and embedded UIs.