Getting started
Introduction
miso is a library for building web and native user interface applications. It provides a React-like programming experience for a simple Haskell dialect that emphasises performance, purity, simplicity, extensibility and composability.
What miso addresses
miso covers the common areas of web development so that you can spend your time on your application:
- DOM manipulation — miso uses a Virtual DOM with a diffing algorithm that is responsible for all DOM modification and
Componentlifecycle hooks. - Event delegation — all event listeners are attached to a top-level element (typically
<body>). When raised, events are routed through the virtual DOM to Haskell handlers that change application state. Both thecaptureandbubblephases are virtualised. - Prerendering — the server delivers HTML before the JavaScript or WebAssembly bootstraps. Instead of an initial draw, the client populates the virtual DOM from the real DOM ("hydration"), which avoids a redraw and helps SEO.
Miso.Html.Renderrenders on the server;misohydrates on the client. - Components — a
Componentis a self-contained miso application bundling its state, the logic that updates it and a function that renders it. Components nest to arbitrary depth. - Custom renderers — the underlying DOM operations are abstracted so a different rendering engine can be plugged in. This is how miso targets mobile devices through Lynx.
- Lifecycle hooks —
mountandunmounton components,onCreatedandonDestroyedon elements. Commonly used for component communication and third-party JavaScript integration. - State management — component
modelstate is manipulated withMiso.LensorMiso.State. - HTTP / cookies —
Miso.Fetchwraps the Fetch API andMiso.Cookiethe CookieStore API, each with an asynchronous callback-basedEffectand a synchronous_-suffixedIOvariant.
Architecture
- React — miso implements a subset of the React architecture internals: components, lifecycle hooks, virtual DOM, event delegation, along with the Fragment, Props and Context API features.
- Elm — miso also implements the Elm architecture (model–view–update) and the
mailboxcommunication pattern.
Native (mobile)
Beyond the browser, miso targets native mobile devices by driving the Lynx runtime instead of the DOM. The same MVU model, Component API, event delegation and virtual-DOM diffing carry over unchanged — only the element vocabulary differs. The native backend is gated behind the native cabal flag; web and WASM builds are unaffected. See the native section for the dual-thread architecture.
Where to next
- Installation — set up the WASM toolchain and build the sample app.
- Your first Component — the counter, line by line.
- Thinking in miso — how to structure a real application.