moxzi
Docs / Browser / moxzi-web overview

moxzi-web overviewalpha

What moxzi-web runs in a browser, how it compares with moxzid and the Internet Computer, and when to use page or worker mode.

moxzi-web is a JavaScript package that runs compiled Motoko actors inside a web page. It loads the same .wasm file you'd deploy to the Internet Computer and runs it with the same message rules: one message at a time per actor, rollback on trap, upgrades that keep state, timers, and calls between actors.

Use it for offline-capable apps, interactive tutorials and playgrounds, local-first prototypes, or to test an actor's logic in the browser before deploying it.

What runs where#

PartWhat it is
Your actorYour .wasm, run by the browser's WebAssembly engine
The runtimemoxzi_web_bg.wasm, shipped in the package. It implements the IC's system API and message scheduling
The client libraryMoxzi in moxzi.js. You call actors through it, with types from their Candid interface

The runtime is the same code moxzid uses, compiled for the browser, so actors behave the same in both.

Page mode and worker mode#

Page modeWorker mode
Start withMoxzi.start({ glue })Moxzi.start({ worker: true })
Where actors runThe page's main threadA Web Worker
Stopping a runaway messageOnly with meter: truedeadlineMs, or meter: true
HTTPS outcallsNoYes, with http: true and cross-origin isolation
Running the compiler in the pageYesNo, a worker's stack is too small

Everything else, including the method calls on actors, is the same in both modes.

Compared with moxzid and the IC#

moxzi-webmoxzidInternet Computer
Durable stateIndexedDB, or your own storageSnapshot and log on diskReplicated
TimersWhen the page drives them (timerMs or tick())YesYes
Instruction limitsOpt-in (meter: true)YesYes
Certified responsesNoNoYes
Callable from outsideNo, only from the pageOver HTTPFrom anywhere

An actor in a page can call canisters on the IC with ic-agent, in worker mode with http: true.

The compiler in the browser#

The Motoko compiler also runs in a page, and produces the same wasm as moxzi build. That's how the demos on this site compile code you type. It runs on the main thread.

Next steps#

On this pageWhat runs wherePage mode and worker modeCompared with moxzid and the ICThe compiler in the browserNext steps