zobacz/Docs

The rules

Every rule below is labelled with how it is enforced. For the ones marked as errors, the build stops and the message contains the fix. This page is the short version of the AGENTS.md that ships inside the package. Running apps off Cloudflare is covered in Self-hosting.

build error · plain-field-across-resume

State is a signal

State lives in signals. Writing a signal re-renders the component, and its value is snapshotted on the server and restored in the browser. A plain instance field gets neither: a @client method reads its initial value, whatever the server set.

app/cart/page.tsx
// Read with .get(), write with .set().open = createSignal(false); // Durable Object backed: survives reload, syncs across tabs.items = createDurableSignal({ scope: 'user', key: 'cart', initial: [] }); async load() {  this.items.set(await new Cart(appDb()).lines());} @client toggle() {  this.open.set(!this.open.get());}
type error

Handlers receive what you pass

A handler receives exactly the arguments you write, in that order, so the call TypeScript checks is the call that runs. To get the DOM event, pass it explicitly and declare a parameter for it at that position.

anywhere in template()
// Without the event: declare only what you pass.<button onClick={() => this.remove(item.id)}>Remove</button>@client remove(id) { /* id is item.id */ } // With the event: pass it, and declare the parameter.<form onSubmit={(e) => this.save(e)}>@client save(e) { e.preventDefault(); } // It can go anywhere in the list.<button onClick={(e) => this.log('click', e)}>@client log(label, e) { }
build error · undecorated-template-call

Where code runs is a decorator

Methods run on the server by default. @client ships its body to the browser; @rpc keeps the body on the server and gives the client a fetch thunk. An undecorated method is removed from the client bundle, so the build reports an error where template() calls one.

app/inbox/page.tsx
@client  open()   { /* browser */ }@rpc @auth  send()   { /* server; body stripped from the bundle */ }async       load()   { /* server, before the first byte */ }            helper() { /* server only; call it from load() or another server method */ }
build error · relative-fetch-in-load

load() reads the database

load() runs inside the Worker and reads data through a repository. A relative URL there has no origin, so a fetch to /api/… fails and the page renders without its data. HTTP endpoints serve clients.

app/products/page.tsx
// Yes.async load() {  this.products.set(await new Catalog(appDb()).list('demo'));} // Renders an empty page: a relative URL has no origin in a Worker.async load() {  const res = await fetch('/api/v1/products');}
build warning · missing-key-in-list

Lists need a key

With a key, each row keeps its DOM node when the list changes: focus, scroll offset, media playback and open/closed state stay with the right row. Without one, rows are matched by position, so an insert or reorder moves that state onto a neighbour.

app/inbox/page.tsx
{this.messages.get().map((m) => (  <li key={m.id}>{m.subject}</li>))}
convention

Failure is a thrown error

For errors, sign-in and access denied, throw a typed error. The framework renders the app's error page for a browser or a JSON body for an API caller, chosen by the path and the Accept header.

api/catalog/catalog.controller.ts
import { notFound, forbidden } from 'zobacz'; const product = await repo.getBySku(sku);if (!product) throw notFound('No such product');if (!member) throw forbidden('Not a member', { code: 'not_member' });
convention

app/ is pages, api/ is endpoints

app/ holds pages and components. HTTP endpoints are declared in api/<domain>/<domain>.routes.ts and registered on the Router in index.tsx, and SQL lives in repositories. Imports inside an app use the @/ alias, including for a sibling file.

project layout
app/                  pages and components only  page.tsx            /  products/[sku]/page.tsxapi/  catalog/    catalog.routes.ts       paths to controller methods    catalog.controller.ts   HTTP in, HTTP out; no SQL    catalog.repository.ts   SQL lives here, and only hereindex.tsx             builds the Router, exports fetch()