Your schema is the API.

Zonai is a self-hosted backend framework for Dart. Define your tables, write your rules, and get a REST API with auth, live query streams, file uploads, email and cron. Free, open source and MIT licensed.

macOS and Linux in one file · Windows as a zip · all downloads

lib/src/schemas/tasks.dart you write this
// Task is a plain Dart class with these fields.
final class TaskTable extends Table<Task> {
  TaskTable(super.$)
    : id = $.id('id', (s) => s.id,
          fromString: TasksId.new, generate: TasksId.generate),
      title = $.text('title', (s) => s.title),
      isComplete = $.boolean('is_complete', (s) => s.isComplete),
      createdAt = $.createdAt('created_at', (s) => s.createdAt),
      updatedAt = $.updatedAt('updated_at', (s) => s.updatedAt);

  @override
  Task fromRow(RowReader read) => Task(
    id: read(id), title: read(title), isComplete: read(isComplete),
    createdAt: read(createdAt), updatedAt: read(updatedAt),
  );

  final IdColumn<TasksId> id;
  final TextColumn title;
  final BooleanColumn isComplete;
  final DateTimeColumn createdAt;
  final ColumnType<DateTime?> updatedAt;
}

final tasks = table('tasks', TaskTable.new);
Routes you get zonai handles this
  • POST/dbcreate a row
  • GET/dbread one
  • GET/db/listquery many
  • GET/db/countcount matches
  • PATCH/dbupdate
  • DELETE/dbdelete
  • GET/db/streamlive row
  • GET/db/stream/listlive list
  • GET/db/stream/countlive count
12 routes for every table, with bulk writes on /db/many · 0 lines of HTTP code · no codegen step
Live queries

Stop polling.

Every table gets three streaming routes alongside the ordinary reads. The server holds the connection open and pushes a new payload whenever the query result changes. There is no WebSocket server or message broker to set up.

lib/widgets/task_list.dart zonai_client
final sub = client.db.listen
    .list(
      body: StreamListBody(
        table: 'tasks',
        where: Eq('is_complete', false),
        limit: 50,
      ),
      fromJson: (row) => row,
    )
    .listen((tasks) {
      // Fires on connect, then again on every insert,
      // update, or delete that changes this result set.
      setState(() => _tasks = tasks);
    });

await sub.cancel();
simulated demo GET /db/stream/list 0 pushed
  • Ship the migrationtk_9f2a
  • Review auth rulestk_4c81
  • Wire up SMTPtk_7b30
open tasks2

Same rules, same limits

Streams reuse canView / canList (count uses canList) and the matching rate-limit buckets. There is no separate canStream to forget about.

Three shapes

stream-one for a single row, stream-list for a result set, stream-count for a running total. Pick the one your UI actually binds to.

Plain HTTP underneath

GET /db/stream*, JSON in a ?body= query param, events until you cancel. Reachable from anything that speaks HTTP, not just Dart.

Read the streaming guide
Admin dashboard

A control room you did not build.

Every Zonai server serves an admin dashboard at /_. It is compiled in alongside your API, so there is nothing extra to deploy.

The Zonai dashboard open on a tasks table, with seven rows of example data and columns for id, title, is_complete, created_at and updated_at.
The tasks table in the dashboard. Example data from a local test project.

Browse and edit every table

Your schema rendered as a data grid — inline edit, row detail, search and filter (including datetime ranges), foreign-key pickers, and photo columns that show the actual image.

Watch the traffic

Requests and errors over the last 24 hours, active sessions, p95 response time, and per-table row counts. Admin traffic can be excluded so your own clicking does not skew it.

Keep an eye on jobs

Which cron jobs exist, which are running right now, and the errors coming up most often — without opening a terminal or tailing a log.

Exercise the auth flows

Sign-in, one-time passcodes, magic links, password reset and email verification are all real screens, so you can try the flow you just configured.

Built with Jaspr, same as this page. Metrics come from GET /dashboard/metrics, so anything the dashboard shows you can also pull yourself.

On a new project, add lib/src/rules/admin_row_rules.dart before you sign in. See row rules.

In the box

The parts you would have written anyway.

Zonai is opinionated so the boring half of a backend is already decided. Everything below is part of the framework, not a plugin you go shopping for.

A REST API per table

Create, read, list, count, update, delete and three live-stream routes, handled straight from your schema. No handler code and no generation step.

Authentication included

Password sign-up/sign-in, one-time passcodes, and magic links — each a single trait mixed into an auth table. Sessions, refresh, and logout come with it.

Docs

Rules in plain Dart

Table rules run before any SQL. Row rules then check each fetched row, and one failure returns a 403 with no data. Anything you do not override is admin-only.

Docs

Generated Dart client

zonai_client wraps auth, admin auth, db, photos, and email so your Flutter app never hand-rolls an HTTP call.

Docs

Transactional email

SMTP-backed HTML templates with Mustache variables, sent from lifecycle hooks. Built-in templates for the auth flows, custom ones for everything else.

Push notifications

Send from a lifecycle hook to a recipient set named by a query, not a list of tokens. The fan-out pages, checkpoints, resumes after a restart, and clears dead tokens — FCM for Android, APNs direct for iOS.

Docs

Scheduled jobs

Cron-syntax jobs compiled into their own worker, with the full database API and catch-up logic for runs missed while the server was down.

Per-IP rate limiting

A policy class per table and operation, with dedicated buckets for the auth routes and trusted-proxy handling for real client IPs.

One folder to deploy

./zonai build writes everything into build/. Cross-compile for Linux, copy the folder to your server and run it. The server does not need the Dart SDK.

Docs
Straight answers

What Zonai is not.

Every framework has a shape, and pretending otherwise wastes your afternoon. Here is where Zonai stops, so you can decide before you install anything.

Not a full application framework

Zonai is an API server. It renders no HTML and has no view layer. You talk to it from Flutter or Dart with zonai_client, or over plain HTTP from anything else.

Not a managed cloud service

There is no account to sign up for and no per-seat bill. You build your project and run it on a server of your own.

Not a general-purpose ORM

It is opinionated about how APIs are shaped and it uses SQLite. If you need arbitrary joins across Postgres, this is the wrong tool and that is fine.

Quick start

From an empty folder to a running API.

You need the Dart SDK (3.13.x) and the zonai binary. The docs quick start has the full schema, the rules and your first request.

  1. 1

    Start a project

    Put the zonai binary in an empty folder and run dev. It offers to set up the project, writes the starter files and starts a server on localhost:8080. On Windows, use the zip below.

    $ mkdir my_app && cd my_app
    $ curl -fsSL https://github.com/mrgnhnt96/zonai/releases/download/v0.17.0/zonai -o zonai && chmod +x zonai
    $ ./zonai dev
  2. 2

    Add a table and its rules

    Press n in the dev screen to scaffold a schema and its ID type, then fill in the columns. Each table needs a table rules file and a row rules file, or its requests are refused.

    # press n in the dev screen, then write
    lib/src/schemas/tasks.dart
    lib/src/rules/task_table_rules.dart
    lib/src/rules/task_row_rules.dart
  3. 3

    Migrate

    From a second terminal, generate a migration from your schema and apply it. Press s twice in the dev screen to restart the server, and the REST API for the new table is live, stream routes included.

    $ ./zonai db migrate generate --name tasks
    $ ./zonai db migrate apply

macOS and Linux in one file, Windows as a zip

The CLI runs from your project root. The universal build works out your OS and architecture by itself, or take the exact build you need.

macOS + Linux

Universal: detects your OS and architecture

One self-extracting file containing macOS arm64, macOS x64, Linux x64 and Linux arm64. It caches the right build on first run. Not a Windows executable — Windows has its own zip.

Windows

x64

Extract the zip and put zonai.exe in your project root.

All builds

Already installed? ./zonai version check tells you if there is a newer build, and ./zonai version update replaces the binary in place. The CLI also asks GitHub for the latest release when it runs; add --no-version-check to skip that.

For coding agents

Your assistant can read the manual too

A curated index for LLMs lives at llms.txt. Inside a project, ./zonai ai writes framework reference sheets into the repo for Claude Code, Cursor, Copilot, Windsurf, and Cline — so every developer and every agent shares the same context about how your backend is built.

$ ./zonai ai all      # every supported tool
$ ./zonai ai claude   # CLAUDE.md
$ ./zonai ai cursor   # .cursor/rules/zonai-*.mdc

Write the backend in the language you already ship.

Zonai is open source under the MIT license, so you can read every line before you build on it.