Cloudflare-native · resumable · self-hostable

Built on Workers.
Runs on your servers too.

zobacz compiles to the Cloudflare Workers API and treats D1, Durable Objects and R2 as its standard library. The same app, from the same cloudflare.config.ts, also runs on your own hardware.

This page is a zobacz app. It is rendered on the server; the browser loads the resumer and this page’s component code, and keeps the server’s DOM.

One file, both sides of the wire

A decorator says where each method runs. The build splits the class, removes server code from the client bundle, and stops with an error when the bundle would behave differently from the source.

app/inbox/page.tsx
import { Z, client, rpc, auth, createSignal } from 'zobacz'; export default class Inbox extends Z {  // Local to this instance. Read with .get(), write with .set().  filter = createSignal('unread');  messages = createSignal([]);   // Runs on the server, before the first byte. Talk to D1 directly.  async load() {    this.messages.set(await new Messages(appDb()).list('unread'));  }   // Runs in the browser. This body is the only thing that ships.  @client async show(kind) {    this.filter.set(kind);    this.messages.set(await this.fetchByKind(kind));  }   // Runs on the server. The client gets a typed fetch thunk; the body  // is removed from the bundle, so your queries stay in the Worker.  @rpc @auth async fetchByKind(kind) {    return new Messages(appDb()).list(kind);  }   @auth  template() {    return (      <ul>        {this.messages.get().map((m) => (          <li key={m.id}>{m.subject}</li>        ))}      </ul>    );  }}

See it work

This counter reports on itself: the attribute the compiler emitted for its buttons, and its own code chunk with the size and time it loaded. Both are read from its DOM and the browser’s resource timing.

0
Emitted for the +1 button
reading…
This component's code, loaded with the page
reading…

Resumed in the browser

The browser keeps the DOM the server rendered. Each component's code loads with the page and picks up the state the server sent, and one delegated listener per event type routes events to the right method.

The compiler holds the invariants

The compiler checks every zobacz rule. A violation is a type error or a build error, and the message contains the fix: state that must be reactive, arguments that must line up, a server-only value read in the browser, a list that needs a key.

Built on Workers

D1, Durable Objects, R2 and KV are the standard library. Apps call the Workers API directly, and each task has one way to do it, so the API stays small.

Mistakes become build errors

zobacz looks like React and works differently, so code can compile, pass the type checker and still behave wrongly. The build checks for those cases, and the error message names the fix.

terminal
$ npm run build lintHandlers: 1 component-rule violation(s):  [plain-field-across-resume] app/product/page.tsx:41:35    `this.sku` is a plain field assigned in load() (server) and read    here in @client `addToCart` (browser). Only signal state crosses    the SSR-to-resume boundary, so this reads the field's initial    value, not what load() set.    -> Declare it as `sku = createSignal('')`, assign with       `this.sku.set(...)` in load(), read with `this.sku.get()`.

The whole API

Each task has one API.

ConceptHowWhat it does
Local statecreateSignal(0)This instance, this visit.
Shared statecreateDurableSignal({ scope: 'user' })Durable Object backed. Survives reload, syncs across tabs.
Browser code@client method()The body ships to the client.
Server code@rpc method()Client gets a fetch thunk. Body stripped from the bundle.
Data loadingasync load()Runs before render. Read the database directly.
HTTP routesRouter → controller → repositoryDeclared in api/.
Failurethrow notFound()Renders the error page, or JSON for an API caller.

Two hosts, one codebase

Cloudflare runs Workers on workerd, and workerd is open source. arbeit runs your app on it in Docker, driven by the same config Cloudflare reads, so you choose where each deployment runs.

shell
# Deploy to Cloudflare.cf deploy # Or run the same app, from the same cloudflare.config.ts,# on your own hardware.arbeit up

Start

A new app is one command. It boots server-rendered, with a durable counter wired up.

shell
npx --registry=https://npm.commernauts.com zobacz new my-appcd apps/my-appnpm run dev

Writing zobacz with an AI agent? The package ships an AGENTS.md with the rules the compiler enforces, in a format coding agents read.