Get Started
Quickstart

From zero to six native GPUs in minutes.

Install the MoonBit toolchain, scaffold an app with one command, draw its first frame and pack it for the web on WebGL 2.

Three steps

Install, scaffold, run.

Step 01

Prerequisites

The MoonBit toolchain, Git, and Node.js for the web target (it compresses assets and runs esbuild). Native packing also needs that platform's toolchain unless you use the prebuilt wasm runtime.

# macOS / Linux $ curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash $ moon version $ git clone https://github.com/AFK-surf/monoid.git $ cd monoid
Step 02

Scaffold & check

mbui init writes mbui.json, a moon.mod importing mbui, a moon.work naming your mbui checkout, and src/app with a first window. mbui check loads the manifest with every variant and override applied and prints what it resolved to.

$ libs/mbui/scripts/mbui init ../my-app \ --name "My App" --id dev.example.myapp \ --mbui "$PWD/libs/mbui" $ libs/mbui/scripts/mbui check ../my-app/mbui.json \ --runtime wasm
Step 03

Run & pack

Open the app in a macOS window, then pack it for the web: a static index.html, host.js and pre-compressed assets that draw on WebGL 2. Add more targets with a comma.

$ APP=app MBUI_APP_MOD=../my-app \ libs/mbui/scripts/mac.sh run $ libs/mbui/scripts/mbui pack ../my-app/mbui.json \ --target web --out ../my-app/dist

What mbui init writes in src/app

One window, made once as a tree. Change the words, rebuild, and read the docs on views and signals to make it react.

Views & signals
///| fn main { @ui.run_tree("My App", fn(root) { root .grow(@view.Is(1.0)) .ground(@view.Is(0xF5F3EFFFL)) .pad(@view.Is(24.0)) .box(fn(card) { card.words(@view.Is("Hello, My App!"), ink=0x24272BFFL) |> ignore }) |> ignore }) }
Six targets

One core, six thin hosts.

The same MoonBit core draws every pixel. Each host only puts frames on screen and feeds input, on the platform's own GPU API.

Platform GPU Host --target Output
macOSMetalObjective-C · AppKitmac.app · .zip · .dmg
iOSMetalObjective-C · UIKitios.app · .ipa
AndroidOpenGL ESC · JavaandroidSigned APK
WindowsDirect3D 11C/C++ · Win32winPortable · .zip · setup
LinuxOpenGL ESC · GTK 4linux.tar.gz · .deb · AppImage
WebWebGL 2JavaScript · host.jswebStatic site · PWA · .gz/.br

With --runtime wasm, the five native targets need no C, Xcode or MSVC per app: the app's .wasm goes into a prebuilt mbui-runtime shell.

Questions

What developers ask first. The docs go deeper on each.

Why MoonBit?

One language compiles to native C for every desktop and mobile host, to wasm for the prebuilt runtime shell and to JavaScript for the browser. The framework, its tools and its build checks are all written in it, so there is one toolchain from the first frame to the release.

Why draw on the GPU instead of the DOM or a WebView?

Because the same core draws the same pixels on every platform, a test can read exactly what will be drawn from the Tester's draw list, and motion can be computed for any moment. Layout, text and drawing are mbui's own: its flexbox passes Yoga's tests and its text segmentation passes Unicode's.

How big is the WebGL 2 bundle?

It depends on what your app includes, so measure it: libs/mbui/scripts/size.sh web reports app.js and host.js raw, gzip -9 and brotli -q 11, which is what a browser downloads. mbui pack minifies with esbuild and writes .gz and .br files next to each asset.

Can I bring my own design system on top of @headless?

Yes, that is what it is for. Each headless control takes a look function from its caller; a look library such as sf-ui or liquid-glass is just a set of those looks over the same behaviour. Write yours as a module beside mbui that imports only mbui.

How does deterministic UI testing work?

A Tester runs the tree against a fake host. Tests press, type and declare moments with run_for, then assert on the screen-reader tree or the draw list. Every test also runs at 60, 120, 24 and 7 fps and must give identical results, so there is nothing to wait for and nothing flaky to retry.

What are the licenses?

mbui and sf-ui are MIT. liquid-glass is a port of Kyant0/AndroidLiquidGlass and keeps its Apache-2.0 license. Third-party data, tests and code carried by mbui keep their own licenses, listed in THIRD_PARTY_NOTICES.md.

Your first frame is drawn. Keep going.

Learn how views, signals, motion and tests fit together, or browse the components you can build on.