Quick Start
Install the CLI, create a TypeScript app, and run it in a native window. This guide also covers markup reloads, core checks, and release builds. To write the app core in Zig, use the zig-core template.
Prerequisites
- macOS 11 or newer, Linux, or Windows
- Node.js 24+ for the default TypeScript scaffold — the TypeScript frontend (the checker) and core dev loop run under it at build and dev time; scriptc 0.2.5 installs a native compiler with Node. The binary you ship carries no JS runtime. A Zig-core app (
--template zig-core) needs Node only when it declares relational SQLite, whose schema checker and migration generator run at build time.
Get the CLI
The CLI configures the SDK and toolchain:
- The SDK location. Apps build against the SDK the CLI ships with —
native initrecords the path automatically (override with--framework <sdk path>). - The Zig toolchain.
native dev|build|testuse the Zig on your PATH when its version is compatible, and otherwise offer to download the pinned version into~/.native/toolchains/(checksum-verified; pass--yesto skip the prompt in scripts). The toolkit requires Zig 0.16.0 — if you learned Zig on an older version, Zig 0.16 Notes maps the standard-library changes.
Create an app
The CLI generates a counter app and manages its build graph under .native/build/. The project contains:
| File | Purpose |
|---|---|
src/core.ts | The logic: Model, Msg, update — plain TypeScript, compiled to native code at build time |
src/app.native | The entire UI: elements, layout, bindings, and message dispatch |
app.json | App manifest: identity, window and view declarations, permissions, security policy. Its $schema enables editor completion and validation; existing app.zon manifests remain supported. |
assets/icon.png | The app icon source: one square image packaging turns into every platform's icon artifacts |
package.json, tsconfig.json | The editor surface: stock editor TypeScript resolves @native-sdk/core with full IntelliSense, and the tsconfig mirrors the checker's own compiler options |
.gitignore, README.md | Ignores for generated directories, and the commands on this page |
The CLI copies @native-sdk/core into node_modules for editor completion and refreshes it during check, development, and build commands. Builds use the SDK selected by the CLI rather than this editor copy.
The build detects the core language from the source files. Use native init my_app --template zig-core for src/main.zig and generated Zig tests in src/tests.zig. Add --full to either template to generate app-owned build files.
Run it
The first run compiles the app and the SDK. A native window opens with a counter. Its view is in src/app.native:
Markup reads values ({count}) and dispatches messages (on-press="increment"). The core changes state through update and requests external work through effects. The generated counter also uses a clock effect and a one-second timer. The TypeScript template declares these through Cmd and Sub; the Zig template uses fx.wallMs and fx.startTimer:
Bindings use field names exactly as declared: {tickCount} in TypeScript and {tick_count} in Zig. Helpers such as {total} provide derived values. See App Model for the runtime loop and TypeScript Cores for core authoring.
Edit while it runs
src/app.native is embedded into the binary and watched while native dev runs — native dev runs a Debug build by default, which is what arms the hot-reload watcher. Edit it — change a label, add a button — and the window updates while preserving the count. Parse failures keep the last good view on screen. A src/core.ts edit is different: the core rebuilds through the external core compiler and the app restarts — use native dev --core (next section).
Run the core under Node.js
native dev --core runs src/core.ts under Node.js with a virtual host. Send messages as JSON lines, inspect the committed model and effects, and advance a virtual clock to fire timers. This mode does not open a window or render the UI:
The core file can run under Node.js during development and compile to native code for the app. Pair it with --script msgs.ndjson --watch to replay a scenario on every edit.
Check it
native check validates the whole tree without building anything: src/core.ts runs the subset checker (typecheck plus the app-core rules, with diagnostics that explain the rule and a suggested fix), then every .native file under src/ and app.json:
Without a built model contract, once a build has produced the model contract, the markup pass also verifies bindings, iterables, and message tags against the core's Model/Msg. Markup errors come back with file:line:column and a teaching message (native markup lsp provides the same diagnostics plus completion and hover in your editor). native test runs the app's test suite; the Zig template additionally scaffolds src/tests.zig — full-loop UI tests that click buttons through typed dispatch, headless, on any machine. See Testing for the full tiers, including driving the live app from the outside with automation.
Build a release binary
This produces an optimized binary and tells you where it landed:
(The binary name comes from app.json: native init my_app sets "name": "my-app".) Where native dev runs a Debug build to arm hot reload, native build produces an optimized ReleaseFast binary. The TypeScript core compiles to native code inside it — no JS engine, no interpreter. From there, Packaging turns it into a distributable app bundle with native package.
Escape hatch: own the build
If the app outgrows the managed graph — extra build steps, custom sources — run native eject once. It writes a build.zig/build.zig.zon you own into the app and never touches them again; native dev|build|test keep working, now driving your files through zig build. See the CLI reference.
Next steps
- App Model — the model/message/update loop, wiring, and hot reload
- TypeScript Cores — the app-core subset, effects, subscriptions, and the dev loop in depth
- Native UI — every element, attribute, and pattern in the markup
- Components — the component catalog
- State & Data Flow — derive-don't-store, bindings, and text editing state
- Zig 0.16 Notes — the standard-library idioms this SDK uses, mapped from the compile errors older Zig habits produce
- Examples — complete apps in the repository, from a calculator to a native shell
- Web Content — the secondary path for apps that embed an existing web frontend
- Platform Support — what each host supports today