Getting Started
This page walks you through standing up a running HTTP service in about five minutes. The full step-by-step tutorial lives in Hello world.
Requires Zig 0.17.0
zero main targets Zig 0.17.0. Install it first (see ziglang.org) , an older toolchain will fail to build.
5-minute quickstart
1. Scaffold a project
mkdir hello-zero && cd hello-zero
zig init
zig fetch --save https://github.com/im-ng/zero/archive/refs/heads/main.zipTIP
main tracks the 0.5.4 line on Zig 0.17. To pin a release, use a tag such as refs/tags/v0.5.3.zip. That one targets Zig 0.16, so install Zig 0.16 for it.
2. Wire up the dependency
In build.zig.zon, declare the zero dependency. Note the minimum_zig_version field:
.{
.name = .hello_zero,
.version = "0.0.1",
.minimum_zig_version = "0.17.0",
.dependencies = .{
.zero = .{
.url = "https://github.com/im-ng/zero/archive/refs/heads/main.zip",
.hash = "PASTE_THE_HASH_ZIG_FETCH_PRINTS",
},
},
.paths = .{ "build.zig", "build.zig.zon", "src" },
}zig fetch --save writes the URL and the hash for you. Paste the hash it prints if you fill the manifest by hand.
In build.zig, expose zero as a module to your executable:
const zero = b.dependency("zero", .{});
const exe = b.addExecutable(.{
.name = "hello",
.root_module = b.createModule(.{
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
}),
});
exe.root_module.addImport("zero", zero.module("zero"));
b.installArtifact(exe);3. Write the app
Here's src/main.zig:
const std = @import("std");
const zero = @import("zero");
const utils = zero.utils;
pub const std_options: std.Options = .{ .logFn = zero.logger.custom };
pub fn main(init: std.process.Init) !void {
var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);
defer arena.deinit();
const app = try zero.App.new(arena.allocator(), init.io, init.environ_map);
try app.get("/json", jsonResponse);
try app.run();
}
fn jsonResponse(ctx: *zero.Context) !void {
try ctx.json(.{ .msg = "hello zero!" });
}4. Configure via .env
zero reads all its config from environment variables, following the 12-factor model.
Create configs/.env:
APP_ENV=dev
APP_NAME=hello-zero
APP_VERSION=1.0.0
LOG_LEVEL=debug5. Run it
zig build run
# INFO Loaded config from file: ./configs/.env
# INFO Starting server on port: 80806. Hit it
curl localhost:8080/json
# {"msg":"hello zero!"}
curl localhost:2121/metrics # Prometheus metrics, already live
curl localhost:2121/.well-known/health # liveness probeThat's the full loop: configure, register routes, then call app.run().
Everything else, databases, queues, auth, tracing, is opt-in through .env.
Install the zero CLI
Prefer a prebuilt binary over building from source? The installer fetches the latest zero release for your platform and drops it in /usr/local/bin:
curl -fsSL https://im-ng.github.io/zero/install.sh | sh
# pin a version:
sh install.sh v0.5.3
# preview without downloading:
ZERO_DRY_RUN=1 sh install.shIt detects your OS/arch (Linux/macOS, x86_64/aarch64), verifies the download against a SHA-256 checksum, and strips the macOS quarantine flag. The prebuilt binary dynamically links librdkafka and OpenSSL. Install them first (apt install librdkafka-dev libssl-dev on Linux, brew install rdkafka openssl on macOS). DuckDB is only needed for the zero migrator subcommand.
Run the official examples
The framework ships complete, runnable example apps in its examples/ directory:
zero-basic— a full HTTP microservice with REST, Postgres/SQLite, Redis, GraphQL and observability. It ships a multi-stageDockerfile.multi-stageready for Kubernetes.zero-cli— a command-line app built onApp.newCmd/app.runCmd(see CLI Apps).
git clone https://github.com/im-ng/zero
cd zero/examples/zero-basic
zig build run # boots the demo service on :8080Why zero?
zero is a strongly-opinionated Zig web framework built on http.zig.
It targets zero-allocation hot paths while keeping development ergonomic.
Zig, not a managed runtime. There's no garbage collector, no JIT, and no VM. You manage memory yourself and ship a single static binary. The developer experience feels closer to Go than to a heavyweight runtime.
Config over code. Following the 12-factor model, you attach built-ins through
.envinstead of hand-wiring clients and middleware. These built-ins cover databases, queues, caches, auth and observability.Ready for microservices out of the box. REST, auto-CRUD, GraphQL, protobuf, pub/sub, scheduling, rate limiting, structured logging, metrics and tracing are all first-class.
What's included
.envbased configuration to boot the app- Drop-in support for well-known technologies
Postgres/SQLite/DuckDB: seed data on startup, manage migrations with ease- NoSQL through
Cassandra - Timeseries
InfluxDB - Search through
Solr - KV Store:
Redis,NATS KV,Memory,SQLite - Cache:
Redis(withnats_kv/sqlite/memorybackends) - Pub/Sub:
MQTT,NATS,Kafka - File Store:
Local,S3,FTP,SFTP Authentication: OAuth, API Key, Basic, Role-Based Access Control (RBAC)
- REST standard out of the box, including Auto CRUD resource handlers
- GraphQL-over-HTTP and Protobuf-over-HTTP
- Structured logging with remote log-level hot reload
- Scheduled tasks (cron), one-off or repeating
- Rate limiter middleware (IP / header / custom-key modes)
- Websockets & HTMX CRUD
- Swagger / OpenAPI rendering
- Application metrics and distributed tracing for observability
The full capability matrix is on Feature Parity.