Runtimes
The .egg file
Export bakes a project into a compact binary: artboards, animations, state machines, view models, and the pictures, sounds and fonts it needs (or, with --referenced, a folder of assets your app hands over at run time). A bundle (.eggs) holds several artboards.
Web
The web runtime is WebAssembly plus a small helper, egg-player.js, that sizes the canvas, runs the frame loop and forwards pointer, wheel, keyboard and text input.
import init, * as egg from "./egg_web.js";
import { mount } from "./egg-player.js";
await init();
const bytes = new Uint8Array(await (await fetch("hatch.egg")).arrayBuffer());
const view = mount(egg, document.querySelector("canvas"), bytes, {
machine: "hatch", // "" = the first; null = play the first animation
fit: "file", // "file", "layout", "expand", "contain", "cover", or "fill"
layoutScaleFactor: "auto", // number or "auto" for Fit.Layout logical scaling
});| Option | Does |
|---|---|
artboard | Which artboard of a bundle ("" = the first). |
fit | How the artboard meets the canvas: "file" (use the file's setting), "layout", "expand", "contain", "cover", or "fill". |
layoutScaleFactor | Positive number or "auto" to scale logical artboard units in "layout" fit (see Responsive layouts). |
renderer | "canvas" (default, Canvas2D) or "pixels" (software, exact). |
openUrls | Follow "open URL" events (default true). |
sound | Play audio events (default true). |
onEvent | A function called with every event the file reports. |
semantics | Mirror tappable shapes as accessible elements (default true). |
Native and engines
One runtime written in Rust, with a C API and bindings on top of it:
| Platform | Binding |
|---|---|
| Web (full & lite) | @egg/player and @egg/player/lite (793 KB gzip, Canvas2D) |
| React Native | @egg/react-native (iOS Metal + Android ViewManager) |
| iOS, macOS | Swift package & XCFramework |
| Android | Kotlin (AAR) |
| Flutter | Dart packages (runtime and a player widget) |
| Unity | C# package |
| Unreal | Plugin |
| C, C++ and anything with an FFI | egg.h and egg.hpp |
Driving it from code
Every runtime exposes the same calls: start a state machine, set its inputs (set_bool, set_number, fire), read and write view model properties (vm_set_number, vm_fire, …), read the current state and take the events the file reported.
Generate strongly-typed wrappers for your state machines and view models straight from a baked file:
egg typegen dashboard.egg --lang ts -o src/dashboard.gen.ts egg typegen dashboard.egg --lang swift -o DashboardEgg.swift