Canica: deploy, schema changes, sign-in, dev tools
For people running Canica apps. App code is covered by GUIDE.md.
Install
curl -fsSL https://get.canica.app | sh # the CLI in ~/.canica (and Node.js there, if the machine has no recent one)
canica new my-app && cd my-app && canica dev
Run the installer again to update. An app's own canica (in its node_modules) runs the commands inside it.
Deploy
canica login # once: Google sign-in in the browser; the token stays in ~/.canica/credentials.json
canica deploy # in the app's directory → https://<name>.canica.run
canica deploy checks that you are signed in, runs typecheck, lint and tests (it stops at the first failure;
--skip-checks skips them when you just ran them), builds the client and the server on your machine, and uploads
them to the platform's deploy service (api.canica.app). The first deploy reserves the name (--name, default: the
package name; if someone has it, nothing is deployed: pick another with --name) and writes canica.json with the
app's id (later deploys go to that app and ignore --name): commit it, so another
machine or CI (CANICA_TOKEN from canica token create) deploys to the same app. Each app is a Cloudflare
Worker with one SQLite Durable Object (all its data); its secret lives in the deploy service, not on your machine.
canica apps: your apps and your organizations' apps (with their owner).canica logs: the app's last log entries.canica rollback: the previous version serves again (code and assets; the data stays as it is).canica delete: the app and its data, for good. Its name stays yours (or your org's): nobody else can take it, since links and installed apps still point there. Everyone who had allowed the app to sign them in is asked again by the next app at that name, even if it is yours.canica token create [label] | list | revoke <id>: tokens for CI.canica usage: today's requests and changes, the database's size and the uploaded files, against the limits below. Past a daily limit the app answers 429 / refuses changes with a readable error until the next UTC day;canica logs,dbandrunkeep working.
Free plan limits
There is one plan, free. Its limits keep the platform up for everyone:
| What | Limit | Counted | Past it |
|---|---|---|---|
| Requests | 200,000 per app per UTC day | HTTP requests and WebSocket messages that reach the app (uploads too; static files and file downloads do not), scheduled jobs | 429 until the next UTC day |
| Changes | 50,000 per app per UTC day | client mutations, and actions' and scheduled jobs' mutations for a person | LimitReached until the next UTC day |
| Database | 1 GB per app | the SQLite database's size | changes refused (LimitReached), reads work |
| File storage | 5 GB per app | all uploaded files together | uploads refused (StorageFull) |
| One file | 25 MB | each upload or ctx.files.store |
FileTooLarge |
| Image resizing | 5,000 unique transformations a month, for the whole Cloudflare account (Cloudflare Images Free) | each width of each image, once (then stored) | sized links serve the original until the next month |
| Emails | 100 per app per UTC day | (yield* Email).send calls that were queued, once per email however many tries (the app counts, the mail relay counts again) |
EmailLimitReached (per: "app") until 00:00 UTC |
| Emails to one person | 10 per app per person per UTC day | the same, per recipient | EmailLimitReached (per: "recipient") |
| Complaints | 3, and at least 0.3% of what the app sent, in 30 days | people marking its emails as spam | the app may not send email until the operator resumes it |
| Bounces | 10, and at least 5% of what it sent, in 30 days | hard bounces | the same |
| Deploys | 50 per person per UTC day | canica deploy runs that went live, by whoever deploys |
refused with a message until 00:00 UTC |
| Apps | 10 personal apps per person, 25 per organization | reserved names (deployed or not) | canica deploy refuses a new one |
| Organizations | 10 owned per person | canica org create refuses |
|
| Secrets | 50 per app, 5,000 bytes each | canica secrets set refuses |
Files
Apps with file() fields (see the guide) keep uploads in their own Cloudflare R2 bucket, canica-app-<name>-files,
created by the deploy service on the first deploy that needs it and bound only to that app's Worker (the app's code
runs there: a bucket shared by apps would let one read another's files). Uploads go from the Worker straight to the
bucket (the app's Durable Object only grants a permit and records the file; a request without Content-Length gets
411, which browsers never send). File links are signed with the app's secret
and served by the Worker (/_canica/files/<id>), on the app's origin, with nosniff, a sandboxing CSP and only safe
types shown inline (images but SVG, PDF, audio, video, plain text; anything else downloads). Files no row refers to
are deleted (24 h after upload if never stored). canica db purge of a file field deletes its files; canica delete
empties and deletes the bucket. The dev server keeps them in .canica/files.
Sized links (files.url(id, { size })) are resized by Cloudflare's Images binding (IMAGES, bound with the bucket):
each width of each image once, as WebP, stored next to it (<id>/w320.webp) and deleted with it, with the Cache
API in front. Nothing to enable: the binding works on the account's Images Free plan (5,000 unique transformations a
month, https://developers.cloudflare.com/images/pricing/) with the same token. Past that, or on an account that
refuses the binding (the deploy then goes on without it and says so), sized links serve the original.
Apps send typed templates to their own users (see the guide). Deployed, the app's Worker holds no provider key and
is not trusted to check itself: it posts each email (the rendered body, the recipient's address and the sign-in
proof) to the deploy service's mail relay (POST https://api.canica.app/v1/mail/send, authenticated with a
token derived from the app's secret), which decides:
- Sending is on for the platform (
EMAIL_MODE) and for this app (not suspended). - The recipient signed in to this app: the sign-in service's assertion (ECDSA, addressed to the app's origin) that
the app stored at their last Google sign-in names this address, which Google verified. Only a real sign-in gives
it: sessions carried over (the v0.58 cookie move) or renewed have none. Without it
sendfails withNotARecipient(reason: "sign-in-again"); when it is the person's own email, canica/ui shows them a "Sign in again" button (the broker remembers consent: one tap, or none), which stores the proof. - The app's access still lets them in (the platform's own list for
org/private). - They did not unsubscribe from this app or mark it as spam, and the address never hard-bounced (on any app).
- 100 emails a day per app, 10 a day per person.
- The frame: the app's name and icon above the body, the footer "You're getting this because you use
· Unsubscribe", and the headers List-Unsubscribe: <https://mail.canica.run/u/…>,List-Unsubscribe-Post: List-Unsubscribe=One-Click(RFC 8058) andAuto-Submitted: auto-generated. The unsubscribe link is signed per app and address and served by the deploy service onmail.canica.run(that host serves nothing else): GET asks (link scanners do not unsubscribe anyone), POST unsubscribes, and the app is told so its next send fails withUnsubscribed.
It goes out From "<App name>" <<app>@mail.canica.run>, no Reply-To, through Cloudflare Email Service (REST,
/accounts/{id}/email/sending/send). The platform's own domain (canica.app) never sends: a misbehaving app must not
touch the reputation of sign-in and deploys. canica usage shows the day's emails, the sending mode, the last 30 days'
bounces and complaints and whether the app is suspended; canica deploy prints a note when it is.
Why one sending domain, mail.canica.run, and not each app's own (noreply@todo-demo.canica.run)? Once canica.run
is on the Public Suffix List, each <app>.canica.run is its own organizational domain for DMARC (RFC 7489), so a From
there aligns only with DKIM d=<app>.canica.run: one onboarded sending domain per app. Cloudflare Email Service allows
30 sending/routing domains per zone (the apex included), and a wildcard sender signs with the base domain
(d=canica.run), which would stop aligning. mail.canica.run aligns with its own DKIM before and after the PSL entry,
needs one setup, and keeps app mail off the apex. The cost is a shared reputation, which is what the layers above
protect (recipients who chose the app, low limits, one-click unsubscribe, suspension on complaints); the app's name is
the display name and its address's local part, so mailbox filters and our logs tell apps apart. Per-app domains stay
possible later (the relay's From is one line) if Cloudflare raises the per-zone limit.
Modes (pnpm platform deploy … --email outbox|send|off, kept in ~/.canica/platform.json):
outbox(the default): every check runs and the relay records the email (mail_log), but nothing is sent. Apps seesent, exactly as if it went (apps do not know about outbox mode);canica logsandcanica usagesay "recorded, not sent". Safe before the sending domain is set up.send: sent through Cloudflare.off: every email refused (reason: "off"): the platform-wide kill switch.
Setting up Cloudflare Email Service (once, by the account owner):
- The account needs Workers Paid (Email Sending is not on Workers Free; 3,000 emails a month included, then $0.35 per 1,000).
- Dashboard → Compute → Email Service → Email Sending → Onboard Domain:
mail.canica.run(the canica.run zone, on Cloudflare DNS, in the same account). Cloudflare adds and locks its records: MX and SPF oncf-bounce.mail.canica.run, DKIM oncf-bounce._domainkey.mail.canica.run, DMARC_dmarc.mail.canica.run(p=reject). Wait until it shows as verified. - The API token in
~/.canica/cloudflare.envneeds Email Sending: Edit (account) to send, and Queues: Edit for bounces and complaints; or put a separate token with those inCLOUDFLARE_EMAIL_API_TOKENin the same file. - Bounces and complaints:
wrangler queues create canica-email-events;wrangler queues consumer http add canica-email-events(the deploy service pulls it); then Queues → canica-email-events → Subscriptions → Subscribe to events: source Email Sending, domainmail.canica.run, eventsmessage.bouncedandmessage.complained. Its id:wrangler queues info canica-email-events. pnpm platform deploy --domain canica.app --apps-domain canica.run --email send --email-events-queue <id>.- Check it: sign in again to an app that sends (the proof is stored at sign-in), send yourself one, and look at
canica usagethere.
Bounces, complaints, suspension. Every 5 minutes the deploy service pulls the queue's events. A hard bounce
suppresses the address for every app; a complaint blocks that person for that app. An app with 3 complaints and at
least 0.3% of what it sent in 30 days (or 10 hard bounces and 5%) is suspended: its sends are refused with the reason,
the operator log (the deploy service's Workers logs) says [canica operator] email suspended for <app>: …, and its
owner sees it in canica usage and on deploy. Cloudflare also keeps its own suppression list per sending domain;
sends to it come back as bounced. The operator's switch: pnpm platform email suspend <app> <reason>, resume <app>, pull (read events now); --email off for every app.
How the queue works (four steps):
(yield* Email).send(…)checks the recipient and the limits, writes the email to the app's_canica_emails(queued, with an id_emails_…) and a~emailjob, and returns the id. Pages follow it with(yield* Email).status(id)in a query (live).- The job (the Durable Object's alarm) renders the body and posts it to the relay (
sending; leased for 10 minutes, so a Worker that stops mid-try is tried again). - The relay keys on the email's id, per app: the first request decides (send, record in outbox mode, or refuse) and
its answer is kept 7 days; a repeat gets that answer (
replayed: true) and nothing is sent, logged or counted again; a repeat while the first is still out gets 503. The app recordssent(recordedin outbox mode: the app'sstatussayssent; onlycanica logsand the dev outbox tell them apart) orfailedwith the reason (unsubscribed,not-a-recipient,limit,bounced,complained,suspended,off, …). - A try that gets no answer (a timeout after 30 s, the relay down, HTTP 5xx/429) is
queuedagain with exponential backoff (2 min, 10 min, 50 min, ~4 h, 16 h: 6 tries in about 21 h), thenfailed(reason: "relay"). Refusals and permanent provider errors (502 withretry: false) are not tried again. Each try is a line incanica logs(email todayDigest (_emails_…) try 2 of 6 …).
Dev and tests never send: the dev server keeps an outbox at /_canica/dev/emails (dev only; the Worker answers
404), tests list what was sent with t.emails(), and the relay is only in deployed apps.
Where apps live: <name>.canica.run
Apps are served at https://<name>.canica.run; the platform itself stays at canica.app (auth. sign-in,
api. deploys, mcp. the MCP for all your apps, get. the installer). They are two registrable domains on purpose:
browsers draw security lines (cookies, SameSite, storage partitioning, site isolation) around the site, the
registrable domain, so an app's code never shares a site with the services that sign you in and deploy. And once
canica.run is on the Public Suffix List (see docs/psl.md in the repository),
every <name>.canica.run is a site of its own as well: one app cannot set cookies for another or for the whole
domain. Until then apps already never set a cookie on a parent domain (no Domain= attribute anywhere; the broker's
is __Host-).
Apps deployed before v0.47 lived at <name>.canica.app. On their next canica deploy they move: the app gets
<name>.canica.run, and <name>.canica.app stays attached but answers every request with a 308 to the same path
and query on the new address (308 keeps the method and body, so POSTs and MCP calls follow it). Such an app runs
its Worker before the static files on every request (otherwise pages on the old address would be served without
the redirect). Things to know:
- People signed in on the old address sign in again on the new one (sessions are kept per origin); their data is theirs as before. A guest on the old address starts as a new guest.
- Agents connected to
https://<name>.canica.app/_canica/mcpfollow the redirect; reconnect them to the new URL when you can.canica appsshows which apps still redirect from an old address. - The old hostnames are removed in a later version (announced in the changelog): update links before then.
canica deleteremoves both hostnames. canica rollbackto a version from before the move serves it on both addresses, without the redirect, until the next deploy.
Organizations
An organization owns apps the way a person does; nothing is shared implicitly. Roles decide who manages an app, its access level (below) decides who uses it.
canica org create proxus --name "Proxus" # you are its owner
canica org invite proxus ana@proxus.es --role admin # member (default), admin or owner
canica org domain proxus proxus.es # whoever signs in with an @proxus.es Google account joins as a member
canica org members proxus | list | remove proxus <email> | role proxus <email> <role> | delete proxus
canica deploy --org proxus # first deploy: the app belongs to the org
canica apps move my-app --org proxus # an existing app (you manage it and administer the org); --personal takes it back
- Owners and admins deploy, delete, roll back, change access,
db purgeandrun; members list the apps and see their logs and usage. Only owners make or unmake owners; an org always keeps one. Anyone may leave. - An invite turns into membership when that email signs in to Canica (
canica login, or connecting the MCP below); if the person has signed in before, they are a member at once. Org apps let invited emails in right away. - A domain can only be set by someone with an email at it, and not for public mail (gmail.com, outlook.com, …). Members who joined through it stay when the domain is removed.
Secrets (for actions)
canica secrets set GITHUB_TOKEN # asks for the value (hidden), or: printf %s "$TOKEN" | canica secrets set GITHUB_TOKEN
canica secrets list # names only
canica secrets unset GITHUB_TOKEN
The deploy service keeps them for the app (owners and org admins set, list and remove them) and binds each as
CANICA_SECRET_<NAME> on the next canica deploy, where actions read ctx.secrets.<NAME>. Values are never shown.
Order for a new app: you can set its secrets before the first deploy. canica secrets set in a directory without
canica.json reserves the app first (like the first deploy does: --name <name>, --org <slug>), so the first
canica deploy already binds them. Changing a secret later takes effect on the next canica deploy.
Access: who may use an app
The code declares it, app({ access }) in server/index.ts (default signedIn); every canica deploy sends that
level. The app's owner (or an org's admins) can choose another on the deployed app:
canica access # shows it, and whether it is the code's or set here
canica access org # public | signedIn | org | private: wins over the code from now on
canica access reset # back to the code's level (as of the last deploy)
public: anyone, guests too.signedIn(the default): anyone signed in with a Google account.org: only people signed in with Google whose email is a member or invited, or at the org's domain. A personal app: only you.private: only the org's owners and admins. A personal app: only you.
Which one wins: a level set with canica access stays across deploys, whatever the code says, until canica access reset; without one, each deploy applies the code's. canica deploy prints the level in force, and a note when it
got stricter (public → signedIn, …). Leaving public strands guests' data: it stays in the database, but no guest
session reaches it any more and signing in does not bring it back. Apps deployed before v0.51 were public by
default: their next deploy makes them signedIn unless the code declares public (an org/private set with
canica access stays).
The deploy service binds the level in force with its emails and domains on every deploy (CANICA_ACCESS), pushes it
to the app (POST /_canica/admin/access, kept in its database) and pushes it again when the org's people or domain
change. The app enforces it for everything that reads or writes data: pages (live queries and mutations get
Unauthenticated or Forbidden), actions, uploads, its MCP and the approval of agents. Until a visitor may use
it, every route shows the sign-in screen; someone signed in but not let in sees "You don't have access" with a way
to switch account. Static files (the page's code) stay public; data does not. The dev server applies the code's
level (with org/private letting in anyone signed in).
Agents (MCP)
Every app is also an MCP server at https://<name>.canica.run/_canica/mcp: its queries are read-only tools and its
mutations are tools that change data, with their args as JSON Schema. It is Effect's McpServer in its stateless
mode (MCP 2026-07-28): each request stands alone, so a query answers with the data of that moment, it does not stay
live. Clients that only speak older protocol versions cannot connect.
To connect an agent, give it the URL (claude mcp add --transport http todo https://todo.canica.run/_canica/mcp,
or the app's menu → Connect an agent). The agent follows standard MCP OAuth to the app itself: the app opens
its "Connect an agent?" screen, with its own sign-in, and the person allows or denies. The agent then acts as that
person, with the same access rules and daily limits as the app's pages. DELETE /_canica/auth/agent from the
app's page (its session cookie) revokes every agent of that person. Browser sessions never work on the MCP endpoint:
it takes only agent tokens (Authorization: Bearer cna_…). The dev server serves all of it too.
One MCP server for all your apps
https://mcp.canica.app/mcp (also at api.canica.app/mcp) offers every app you may use (yours and your
organizations', within their access scope) as one flat list of tools, named <app>__<tool>
(todo-demo__add), plus apps_list, app_logs, app_usage, app_rollback (owners and admins) and
org_members.
claude mcp add --transport http canica https://mcp.canica.app/mcp
The agent connects with OAuth: the deploy service signs you in with Google and asks you to allow it. Its token
(canica token list shows it as mcp: <client>; canica token revoke ends it) only opens the MCP, not deploys.
A CLI token (canica token create) works as a bearer token too, for headless agents. Each call runs in the app as
your Google account there (the same one you get by signing in to the app; it is created if you never did), with
the app's own rules and daily limits. The service lists and calls an app's tools through its admin routes
(GET /_canica/admin/tools, POST /_canica/admin/call); apps deployed with canica older than 0.43 offer none
until they are deployed again.
Changing the schema (no migration files)
The schema in server/index.ts is the truth. The database is migrated at deploy, before the new version gets any
traffic:
- The deploy service uploads the new version without serving it (a Cloudflare Worker version).
- The running app checks the new schema against the tables and the data (the plan) and applies it, in one transaction, recording the schema's hash.
- Only then does the new version serve every request. It finds the hash it expects and does no schema work when it starts (or wakes up).
canica deploy prints Migrating database… ok (2 changes) and the changes. If some rows do not fit, the migration
fails, or the app cannot be reached, the deploy fails with the plan or the reason ("Not deployed: the database change
failed; the app is still on the previous version."): the database is as it was and the previous version keeps
serving. canica db plan shows the plan without deploying. The dev server does the same check when the schema
changes and refuses a schema the data does not fit (the error appears in the browser).
Why the code serving now migrates, and not the new version: the database is one Durable Object, which runs one
version at a time; a version that is not deployed cannot reach it (Cloudflare gives no preview URL to Workers with
Durable Objects, and a gradual deployment assigns the one object to one version). So the old code applies the new
schema (from its description) and keeps serving on it for the moment until the new version is live. That is safe
because a plan only allows compatible changes: new tables, fields and indexes, hidden (not dropped) fields, and
tightening only what the data already fits. The old code does not know the new columns, so it leaves them empty; the
new version's first start fills the defaults of rows written in between (a tightened rule, though, is not checked again
for rows the old code writes in those seconds). canica rollback relies on the same rule:
older code runs on the newer schema as is.
- Automatic: new tables,
.optional()or.default(…)fields, indexes. A field that becomes.default(…)fills its empty rows with the default. - Only if every row already fits: a stricter field (
.max(40)→.max(10), optional → required), a new.unique. The plan says how many rows do not fit and gives some ids. - Removing a field or a table hides it: the data stays (
canica db purge rooms.topicdeletes it for good). - Another type, a rename or a new required field on a table with rows: add the new field as
.optional(), deploy, fill it with an internal mutation, make it required (and remove the old field), deploy again.
Internal mutations are for backfills and maintenance; clients cannot call them:
export default app({
queries: { … },
mutations: { … },
internal: {
fillSlugs: mutation(function* () {
const db = yield* Db
const batch = yield* db.select().from(rooms).where(isNull(rooms.slug)).limit(100)
for (const r of batch) yield* db.update(rooms).set({ slug: slugify(r.name) }).where(eq(rooms.id, r.id))
return { done: batch.length < 100, processed: batch.length }
}),
},
})
canica run fillSlugs --batch runs it (as a system user) again and again while it returns done: false, each batch
in its own transaction. canica run <name> '{"arg":1}' runs any mutation or action (internal ones too) once. Test them with t.run("fillSlugs").
canica db history lists the schema versions; each one keeps a restore point of the database from just before
it was applied. Every canica db/canica run command talks to the deployed app, or to the dev server with
--url <the URL canica dev prints> (e.g. --url http://localhost:5173; the port changes when it is busy).
Sign-in
People sign in with Google through the platform's sign-in broker (auth.canica.app): apps hold no OAuth secrets.
The broker only sends people back to https://<name>.canica.run (exactly one label, https), the platform's own
api./mcp.canica.app, the old <name>.canica.app addresses while they redirect, and dev servers at
http://localhost:<any port> or http://127.0.0.1:<any port> (not [::1], LAN or Tailscale addresses).
The dev server signs in the same way, with the same screen ("Sign in with Google", no test users). It needs no Canica account, app registration or secret: it signs its own state with
.canica/dev-secret, binds the sign-in to the browser with the same nonce cookie as a deployed app, and checks the broker's assertion, addressed to its own origin (http://localhost:5173), with the broker's public key (read fromhttps://auth.canica.app/providers; it is not secret). An assertion for localhost is useless to a deployed app (each checks its own origin), and the broker never signs a localhost return in silently: Google asks which account first, so no page can hand a signed-in visitor's identity to whatever listens on a local port.CANICA_AUTH_BROKER(andCANICA_AUTH_PUBLIC_KEY) in the environment or.envchoose another broker. Offline, or opened at an address other than localhost, the screen says why instead of offering Google.Test users without Google exist only on the dev server, for scripts:
POST /_canica/dev/test-sign-in{ name, token }(a JSON POST from the dev server's own origin, like/_canica/dev/resetand/seed) →{ token, userId }(name@example.dev). Nothing renders it;scripts/e2e-todo.mjsandcanica storyboarduse it. A deployed app (the Worker) answers 404 there. Tests uset.as(name).Apps that are not public: until signed in (and let in), every route shows a full-page sign-in screen with the app's icon and name and who may use it; after signing in, the browser is back on the page it asked for. No guest sessions exist there.
yield* SignedInViewergives handlers the signed-in viewer.Public apps: everyone gets a guest session automatically.
page({ auth: "signedIn", … })shows a sign-in screen to guests and the page once they sign in (no reload);layout({ auth: "signedIn", … })does it for the whole app. These only hide UI: protect the data withyield* requireSignIn(fails withUnauthenticatedfor guests) on the server as well. Signing in keeps the guest's data: a new account adopts the guest'suserId; signing in to an existing account moves everyuserId()field from the guest to the account (rows that would break a unique index stay behind: merge them inauth: { onGuestUpgrade: mutation(…) }).Server:
yield* Viewer→{ userId, isGuest, isSignedIn, profile? }(profileis for display, never authorize on it).Client:
useAuth(),signInWithGoogle(),signInWithAnotherAccount(),signOut(). UI:<UserMenu />,<RequireSignIn>,<SignInScreen />; replace the full-page screens withsetSignInScreen/setNoAccessScreen.
Running the platform (operators)
From this repository, not the published CLI: pnpm platform (packages/platform, never published) deploys the
platform's own Workers with Alchemy to your Cloudflare account. The canica CLI people install is only for making
and deploying apps: it talks to the deploy service with a Canica token and never holds Cloudflare credentials.
Once per platform, with Cloudflare credentials in ~/.canica/cloudflare.env (CLOUDFLARE_ACCOUNT_ID,
CLOUDFLARE_API_TOKEN) and Google's OAuth client in ~/.canica/oauth.env (after pnpm install):
pnpm platform deploy --domain canica.app --apps-domain canica.run --contact javier@proxus.es # the whole platform
pnpm platform publish --domain canica.app # the installer and package at get.canica.app
pnpm platform token <email> # a token for someone, without the browser sign-in
pnpm platform consents prune [--yes] # forget consents to origins with no app (apps deleted before v0.64.1)
deploy deploys the whole platform, in the order each part needs the one before: the sign-in broker at
auth.canica.app (its keys and platform.json), the deploy service at api.canica.app and mcp.canica.app
(apps at <name>.canica.run), then Canica home at canica.app (and the apps zone's wildcard). Each is its own
Alchemy stack (canica-auth, canica-api, canica-home), a no-op when nothing changed; the flags are saved in
~/.canica/platform.json, so later runs need none. A step that fails stops the run: run it again. publish stays
apart: it releases the CLI, not the platform.
publish first runs the fresh-app check on the tarball it is about to upload, and uploads nothing if it fails:
in a temp dir outside the repository, with an empty HOME, it installs the tarball as the CLI (as install.sh does),
runs canica new (the app depends on that same tarball), then npm run typecheck, npm test, canica lint,
canica build, and canica dev until /_canica/health answers (about a minute). --skip-fresh-check skips it; run
it alone with node scripts/fresh-app-check.mjs [<tarball>] [--keep]. It catches what only shows outside the monorepo:
files missing from the package, the template pointing at workspace paths, dependencies the workspace happens to
provide. (canica new from a checkout, outside the repository, also packs the checkout this way rather than linking
it: a file: link resolves canica's dependencies from the monorepo, giving tsc two copies of React's types.)
Canica home (src/platform/home.ts) is the platform domain's apex, https://canica.app: signed out,
what Canica is, the install command, the guide (/guide, docs/GUIDE.md rendered at deploy) and Sign in with Google;
signed in, your apps (yours and your orgs', grouped by org, with icon, access, last deploy and Open) and apps you
use (the apps of others you allowed to sign you in, with Open and Revoke). It is a launcher, not a dashboard:
nothing there changes an app. Its own Worker (stack canica-home), with no data of its own:
- When the apps domain differs from the platform domain, home also gets its apex and
www(canica.run,www.canica.run) as custom-domain aliases of home. Home returns a permanent 301 tohttps://<platform domain>with the original path and query, before serving assets or handling sign-in. Cloudflare provisions DNS and TLS through the existing Workers Custom Domains permissions; no redirect-rule permission or manual DNS change is needed. App deployments bind only<name>.<apps domain>;wwwis reserved and an empty name (the apex) is invalid. - Every other name in the apps zone resolves too, and reaches home: a proxied
*.<apps domain>record (AAAA100::) and a route*.<apps domain>/*to home, which answers 404 "No app here" (no-store, no sign-in, no cookie). So a name looked up before its app's first deploy is never cached as "no such name" (Cloudflare's default negative TTL is 30 minutes): it answers as soon as the app is deployed.platform deployalso lowers the zone's negative TTL (SOA minimum) to 60 s where the plan allows a custom SOA (Free does not: Cloudflare 1003, a note, and canica.run keeps 1,800 s; the wildcard is what fixes it). An app there is only a route<host>/*to its Worker (since v0.66.0): the wildcard resolves its name and the zone's Universal SSL certificate (canica.run,*.canica.run) covers it, so it needs no custom domain (no DNS record or certificate of its own). The deploy service makes the route on every deploy (removing a custom domain left from before) and removes it with the app; the route is more specific than home's wildcard, and a route wins over a custom domain (checked on canica.run). The deploy service's stack declaresmail.<apps domain>/*.platform deploygives a route to every custom domain in the zone that lacks it, adds the wildcard, then removes apps' custom domains. A zone without the wildcard (apps sharing the platform's domain) still binds each app as a custom domain as well. The token needs "Workers Routes: Edit", "DNS: Edit" and "Zone DNS Settings: Edit" on the apps zone. - Sign-in goes through the broker like any app, but home is first party (like
api./mcp.): no consent screen, and silent when the browser is already signed in atauth.. The broker accepts exactlyhttps://<domain>as a return (no port, no other scheme). Home keeps its own session in__Host-home_session(HttpOnly, this host only: no cookie is ever set for the domain, so nothing reachesapi.,auth.ormcp.). Sign out ends it and the broker's. - Its data comes server to server:
POST api.<domain>/v1/home(the apps of the session's verified email) andPOST auth.<domain>/home/consents//home/revoke(that Google account's consents), each call signed with~/.canica/home.secret(shared by the three Workers asHOME_SECRET) for one person and one operation, for a minute. Without it those routes answer 404.platform deploycreates the secret if missing and gives it to all three. - Pages: no scripts,
default-src 'none', styles from/style.cssonly, images from itself and the apps' domains,frame-ancestors 'none'. Revoke checks the Origin, a SameSite=Strict nonce cookie and that the form was made for the signed-in account.--contact(kept inplatform.json) is the abuse address on every page (defaultabuse@<domain>). Installable (manifest and icons, the marble).
For apps' email, see Email (above): platform deploy --email outbox|send|off (default outbox), --email-domain (default
mail.<apps domain>, attached to the deploy service for unsubscribe links) and --email-events-queue <queue id>.
The token also needs Workers R2 Storage: Edit (and R2 enabled on the account) for apps with files; platform deploy
warns when it cannot manage R2, and such apps' deploys fail with that reason (nothing is deployed) until it can.
--apps-domain is saved in ~/.canica/platform.json (appsDomain) and used by the next commands; without it apps
share the platform's domain (as before v0.47), which the CLI warns about. The apps domain must be an active zone in
the same Cloudflare account, visible to the token in cloudflare.env: the deploy service gives each app a route there
(<name>.<apps domain>/*, under the zone's wildcard). App names that the platform uses (api, auth, mcp, get, www, …) are reserved, on
the apps domain too.
How names cannot collide. The deploy service's registry (one Durable Object, so two requests for one name never
both win) gives a name once, at the first deploy: one DNS label of 3–32 lowercase letters, digits and dashes, never
xx-- at the start (DNS keeps that for punycode, xn--…, which a browser may show as lookalike Unicode), not
reserved, not taken, and not a deleted app's unless you (or your org) had it. Later deploys go by the app's id in
canica.json, not by name. Deleting an app first asks the broker to forget everyone's consent to its hostnames
(POST auth.<domain>/platform/forget, signed with HOME_SECRET). If the broker does not answer, nothing is deleted
and you run it again. In Cloudflare, an app's hostname is its own route (and, in a zone without the wildcard, a custom domain after it). A route to another
Worker that exists, or to none, is refused and nothing is bound. One left by a Worker that no longer exists is taken over.
How live queries update (and how to see it)
A query records what it reads, from the SQL it sends to SQLite (Drizzle's builders and raw sql alike, subqueries
and CTEs included): for each table, the values of a col = value / col IN (…) condition joined with AND
(messages.room="rooms_…", an id one preferred), or the whole table (messages) when there is none; SQL it
cannot follow reads everything. A mutation records the rows it changed (SQLite triggers log the old and new values
of every column, cascades included). The mutation replies as soon as it commits; right after, only the live queries
that read something it wrote run again, once per distinct (user, query, args). A result that is the same as before
(compared as values, not as text) is not sent; one that changed goes as a patch of the last one (rows by id: the
rows that changed, the ids gone, where new ones go), or whole when that is smaller. The reply carries the commit's
version, and the mutation's promise resolves once this page's live queries it affected show that version: a page
always sees its own writes.
On the dev server, the dev tools (⚡ button bottom right, Alt+S, or ?devtools) show this tab's live queries
(and how often each was updated), every mutation from any tab or user with the keys it wrote, which live queries
re-ran (and whether their result changed), how many were not affected, sign-ins, and every live query on the
server. examples/live is a small app made to explore this.