Skip to content

Examples ​

zero ships complete, runnable apps in its examples/ directory on GitHub. They track the 0.5.4 line on Zig 0.17. They're the fastest way to see zero wired up for real. Copy one to use as your starting point.

Every example below is a self-contained app. Clone the repo and run any of them:

bash
git clone https://github.com/im-ng/zero
cd zero/examples/<example-name>
zig build run            # boots the demo (port varies per example)

Reference apps ​

zero-basic ​

A full HTTP microservice that runs zero's main paths: REST handlers, Postgres/SQLite, Redis caching, GraphQL, structured logging, metrics, and health endpoints. It also ships a multi-stage Dockerfile.multi-stage and is the reference app for the Kubernetes deployment guide.

bash
cd zero/examples/zero-basic
zig build run
# or containerize it
podman build -f examples/zero-basic/Dockerfile.multi-stage -t zero-basic .

zero-cli ​

A command-line app built on App.newCmd / app.runCmd. It has sub-commands, flag parsing via ctx.Param, and app.onStartup hooks. See CLI Apps for the API.

bash
cd zero/examples/zero-cli
zig build run -- help

zero-bench ​

The benchmark harness lives at src/bench/main.zig (built with zig build bench). It boots a real zero.App and drives it with a concurrency ramp to measure throughput, latency, and memory. Details and the regression gate are in Benchmark.

Relational & analytical data ​

ExampleShowcasesDocs
zero-sqliteSQLite handlerSQLite
zero-duckdbDuckDB analyticsDuckDB
zero-nosqlNoSQL via CassandraCassandra
zero-timeseriesTime Series via InfluxDBInfluxDB
zero-searchSearch via SolrSolr

Caching, storage & files ​

ExampleShowcasesDocs
zero-redisRedis cachingUsing Redis
zero-filestoreFile Store (Local backend)File Store
zero-s3File Store (S3 backend)File Store
zero-gcsFile Store (GCS backend)File Store
zero-supabaseSupabase SQL and StorageSupabase
zero-starterMinimal app with a production-style DockerfileGetting Started

Messaging & pub/sub ​

ExampleShowcasesDocs
zero-kafka-publisherKafka producerKafka Publisher
zero-kafka-subscriberKafka consumerKafka Subscriber
zero-mqtt-publisherMQTT producerMQ Publisher
zero-mqtt-subscriberMQTT consumerMQ Subscriber
zero-nats-publisherNATS producerNATS Publisher
zero-nats-subscriberNATS consumerNATS Subscriber

HTTP, APIs & services ​

ExampleShowcasesDocs
zero-service-clientOutbound HTTP service-to-service callsHttp Services
zero-graphqlGraphQL-over-HTTPGraphQL
zero-protoProtobuf-over-HTTPProtobuf
zero-autocrudAuto CRUD resource handlersAuto CRUD
zero-authAuthentication (OAuth, API Key, Basic, RBAC)Authentication
zero-websocketWebsocketsWebsockets
zero-streamWebSocket streaming / push updates to clientsWebsockets

Scheduling, migrations & observability ​

ExampleShowcasesDocs
zero-cronzScheduled tasks (cron)Schedule Tasks
zero-migrationManual migrations flowMigrations
zero-otelOpenTelemetry traces and logs over OTLPOpenTelemetry
zero-rate-limitRate limiting with a Redis-backed storeRate Limiter
zero-vault-pgVault secret injection with PostgresVault

UI ​

ExampleShowcasesDocs
zero-todo-htmxHTMX CRUD (uses automated migrations)HTMX CRUD