Backups & Upgrades

Learn how to keep the data in your backend's Jazz directory safe and upgrade it across releases.

What the data directory holds

Everything your main backend stores lives in the directory you pass to sqlite({ path }):

File or folderWhat it is
jazz.sqlite (with -wal and -shm)Rows, history, schemas, permissions, the index of large-value chunks, and the store's identity: its app id, its own id and where its chunks live
blobs/The chunks of large values, unless you chose another place
app-id, store-id, blob-storeCopies of the identity in jazz.sqlite, kept so an earlier release opened on the directory reads the same one
inspect-token-secretA secret: what Inspector agent tokens are signed with (readable by its owner only, never in jazz.sqlite)
jazz.lockHeld by the running process, so a second one on the same directory is refused

jazz.sqlite holds the identity; the files are copies each start rewrites from it. A copy that disagrees with jazz.sqlite (edited, or from another store) is refused with an error naming both, never chosen.

A store keeps the app id it was first started with, and refuses to start for another one. If it was first started with the wrong one, or your app's id changed, stop the backend and set it:

npx jazz-tools store set-app-id ./data <app id>

Guests' device accounts are derived from the app id, so after a change they no longer match the ones their devices hold: change it only for a store whose users haven't relied on the old one.

If your chunks are in another directory (files({ dir })) or a bucket (s3()), they're part of the data too.

Backing up

Back up the whole directory together, and its chunk directory or bucket prefix with it:

  • Keep inspect-token-secret as a secret, apart from the data if you like: it signs Inspector agent tokens. Restoring jazz.sqlite without it revokes every token issued before; a new one is made on the next start.

  • Stop the backend first, or snapshot the disk it's on atomically (a volume snapshot). Copying jazz.sqlite while it's being written can give you a copy that doesn't open.

  • Copy the -wal file with the database. It holds recent writes that aren't in jazz.sqlite yet.

  • Back up chunks at least as recently as the database. A database that refers to chunks the backup doesn't have can't serve those large values.

Restoring

To restore in place, stop the backend, put the files back, and start it again.

jazz.sqlite is the whole store: a copy of it opens as the same store, for the same app, with the same chunks.

To restore into a new place while the original keeps running, such as a staging copy, make the copy a store of its own before it first starts, and give it its own chunk directory or s3() prefix:

npx jazz-tools store detach ./staging-data

Otherwise it claims the original's chunks, and deletes the ones it no longer needs. The copy keeps the app id, so it still serves the same app, and gets an inspect-token-secret of its own, so agent tokens the original issued don't open it.

Apart from that secret and the chunks, jazz.sqlite is the whole store: a copy of it opens as the same store, for the same app, with its large values where they were.

Upgrading between releases

Upgrade by deploying your backend with the new jazz-tools. On start, it opens the data directory in the new release's format and applies your schema, migrations and permissions as usual. Upgrade browsers and backends together: they ship in one bundle, and a release notes when an older client can't talk to a newer backend.

Back up before you upgrade. Releases don't migrate a data directory back to an older format, so rolling back means restoring the backup.

From 2.0.0-beta.0 on, we try not to break the parts that What beta means lists as stable. When a beta release must, it gets an "Upgrading from …" section below, and where feasible the old API keeps working for a deprecation period first. Experimental parts can change in any release.

On Vercel, there's no supported way to back up or export a vercel() core's data yet (jazz#5441). Upgrading keeps the data as long as namespace names the same core, and a different namespace opens a new, empty one. Keeping the old deployment isn't a fallback: the core always runs the newest jazz-tools its Drive has seen, so once the new deployment has woken it, promoting the old deployment again doesn't roll back its data. To try an upgrade first, deploy it to a preview branch: with the per-branch setup, that preview gets a core of its own, separate from production's (a dry run with its own data, not a copy).

Upgrading from beta.0 to beta.1

Kotlin (experimental): install from the GitHub release

jazz-kotlin and jazz-kotlin-android aren't published to Maven Central from 2.0.0-beta.1, so changing the version of a tools.jazz: dependency to beta.1 fails to resolve. Until they're in a Maven repository of our own:

  1. Download the jar (JVM) or the AAR (Android) from the v2.0.0-beta.1 release into libs/, and check it against that release's SHA256SUMS-languages (commands).
  2. Replace the tools.jazz: dependency with the file and the dependencies it used to bring:
build.gradle.kts
// before
implementation("tools.jazz:jazz-kotlin:<version>")
​
// after
implementation(files("libs/jazz-kotlin-2.0.0-beta.1.jar"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
implementation("net.java.dev.jna:jna:5.17.0")
app/build.gradle.kts
// before
implementation("tools.jazz:jazz-kotlin-android:<version>")
​
// after
implementation(files("libs/jazz-kotlin-android-2.0.0-beta.1.aar"))
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.2")
implementation("net.java.dev.jna:jna:5.17.0@aar")
  1. Make the download part of your CI too, or commit the file.

Keep mavenCentral() for those dependencies. Your code and generated bindings don't change for this, and versions already on Maven Central stay there.

Upgrading from alpha.70 to beta.0

2.0.0-beta.0 is the first beta of Jazz 2. Data directories, Vercel and Durable Object cores, and the sync protocol are unchanged from alpha.70: upgrade by bumping every Jazz package to 2.0.0-beta.0 and redeploying, as usual.

The code changes are removals of everything earlier alphas deprecated. Each subsection below names what was removed, who hits it, and what to use instead. Most of them fail at build time ("not exported"), so your typecheck finds whatever a search misses. jazz-tools upgrade is removed too: these sections are the upgrade path, written so you or an AI coding assistant can follow them.

What beta means

From beta.0 on, we try not to break these between beta releases:

  • the TypeScript client and backend APIs (jazz-tools and its entry points);
  • the schema and permissions DSL in schema.ts, and the migrations migrations create writes;
  • the storage format: a data directory a beta wrote opens in later betas;
  • the wire protocol between clients, backends and cores;
  • running your main backend with createJazz, on your own server, on Vercel with vercel(), with its core on another machine through remote(), or with the core in a Cloudflare Durable Object with durableObjects() (and large values in R2).

When a beta must break one of them, its release notes say so, it gets an "Upgrading from …" section here, and where feasible the old API keeps working for a deprecation period first.

These stay experimental and may change in any release: the Rust, Swift, Kotlin and Go clients (Language Support), transformed columns, and running your backend in a Cloudflare Worker with jazzBackend.

Jazz Cloud stays deprecated for new apps; existing apps keep running.

Removed: useSession() (Svelte: getSession())

Deprecated since alpha.66, these hooks are no longer exported, so code that imports them fails to build. Read the signed-in user from the session instead:

Entry pointBeforeAfter
jazz-tools/react, jazz-tools/react-core, jazz-tools/react-native, jazz-tools/expouseSession()useJazzSession().user
jazz-tools/vueuseSession()useJazzSession().snapshot.value.user
jazz-tools/soliduseSession()useJazzSession().snapshot().user
jazz-tools/sveltegetSession().currentconst session = getJazzSession(), then $session.user

The fields change too, as in alpha.66:

Old sessionNew user
session.useruser.accountId
session.identityuser.identity
session.claimsuser.claims
authMode: "external"user?.kind === "backend"
authMode: "local-first"user?.kind === "device"
authMode: "anonymous"user === null

grep -rnE "\b(useSession|getSession)\b" --include='*.ts' --include='*.tsx' --include='*.vue' --include='*.svelte' . --exclude-dir=node_modules finds them. Then run your typecheck: it flags anything the search missed.

Removed: the alpha.61 auth stubs

In alpha.61 these names became stubs that throw JAZZ_API_REMOVED when called. They're gone now, so importing one fails at build time. Only apps that still import them hit this, and those apps have been throwing at runtime since alpha.61.

RemovedUse instead
useJazzAuth, useJazzSessionOwner, useAccountState, accountState (Svelte)useJazzSession() (Svelte: getJazzSession())
createAccountState, createJazzSessionStateuseJazzSession()
createAccountManager, AccountManagercreateJazzClient(config), whose session signs in (initial: "device", createDeviceAccount(), or your backend's user)
createDbcreateJazzClient(config), then session.db
createJazzAppcreateJazzClient(config), or <JazzProvider config={…}>
exportLocalFirstSecretsession.exportDeviceKey()
useLocalFirstAuth, createUseLocalFirstAuth, LocalFirstAuth, BrowserAuthSecretStore, ExpoAuthSecretStore, expoAuthSecretStoredevice accounts on the session: createDeviceAccount(), exportDeviceKey(), restoreDeviceAccount(key)
JazzSessionProvider<JazzProvider session={session}>
JazzSvelteProvider<JazzProvider config={…}>, or <JazzSvelteClientProvider client> for a client you opened yourself
acceptLocalFirstAuth (jazz-tools/backend)acceptDeviceAccounts

Upgrading from alpha.60 has the same mapping, with more detail. Errors that named loginWithBackend or linkWithBackend now name the session's refresh() and linkDeviceAccount() (for example "refresh() and linkDeviceAccount() need a browser: …"). That only matters to tests that match the message.

Removed: the alpha.68 TypeScript aliases

These were deprecated aliases since the device-account rename (see Upgrading from alpha.68). They're gone now, so using one fails at typecheck and build. Only apps that mint device-account proofs for their own backend, or annotate acceptDeviceAccounts() results with the old type, hit this. Nothing on the wire changes.

BeforeAfter
db.getLocalFirstIdentityProof(options)db.getDeviceAccountProof(options) (same options, same token)
type LocalFirstGuest from jazz-tools/backendtype DeviceAccountsAnswer from jazz-tools/backend

grep -rnE "getLocalFirstIdentityProof|LocalFirstGuest" . --exclude-dir=node_modules finds them.

Removed: the alpha.64 schema DSL names

Since alpha.65 these were stubs that threw JAZZ_API_REMOVED. They're no longer exported, so using one fails at build time. The jazz-tools/permissions subpath is removed, and so are the schema and migration exports of jazz-tools/react-native. Only apps whose schema.ts, permissions.ts or migrations/index.ts are still alpha.64-style hit this.

RemovedUse instead
defineApps.defineSchema({ … }) in schema.ts; runtime code imports app from ./jazz.generated
root defineSchema, tables.defineSchema, s.table (import { schema as s } from "jazz-tools")
definePermissions, anyOf, allOf, createSessionContext (root, s.* or jazz-tools/permissions)the defined schema's own definePermissions, anyOf, allOf and session (const { definePermissions } = schema), compiled to jazz.permissions.json
defineMigration, renameTableFromm.defineMigration, m.renameTableFrom (import { migration as m } from "jazz-tools")
defineSliceableApp, schemaToWasmnothing: slicing is gone, and jazz.generated.ts embeds the compiled schema
schema, migration from jazz-tools/react-nativewrite schema.ts against jazz-tools; runtime code imports ./jazz.generated

An app in this shape is an alpha.64 or alpha.65 app: convert it with npx jazz-tools@2.0.0-alpha.70 upgrade before moving to beta.0 (see Removed: jazz-tools upgrade).

Removed: the alpha.68 Rust aliases

Only Rust code that calls the jazz or jazz-server crate APIs directly hits this; TypeScript apps don't. The device-account renames kept the old local_first names as deprecated aliases, and beta.0 removes them, so code that still uses one fails to compile:

BeforeAfter
identity::LOCAL_FIRST_ISSUER, AuthorSubject::LOCAL_FIRST_ISSUERDEVICE_ACCOUNT_ISSUER
sign_local_first_challenge, verify_local_first_challengesign_device_account_challenge, verify_device_account_challenge
local_first_account_iddevice_account_id
Binding::admit_local_first_sessionadmit_device_account_session
admitted_local_first_accounts (testing only)admitted_device_accounts
jazz-server: LOCAL_FIRST_JWT_ISSUER, admit_local_first_jwtDEVICE_ACCOUNT_JWT_ISSUER, admit_device_account_jwt
jazz-server: LOCAL_FIRST_AUDIENCE_HEADERDEVICE_ACCOUNT_AUDIENCE_HEADER
jazz-server: local_first_audience, local_first_founding_appdevice_account_audience, device_account_founding_app

Nothing on the wire changes: the issuer stays urn:jazz:local-first and the header X-Jazz-Local-First-Audience, so existing tokens and sessions keep working.

Removed: hashes in the server's schema list

This changes an HTTP response. GET /apps/<appId>/schemas (admin secret required) no longer returns hashes, deprecated since alpha.54. Read schemas instead: one { hash, publishedAt } per schema, so the old list is schemas.map((s) => s.hash). The sync protocol is unchanged.

// Before
{ "hashes": ["3f…"], "schemas": [{ "hash": "3f…", "publishedAt": 1744011200000 }] }
// After
{ "schemas": [{ "hash": "3f…", "publishedAt": 1744011200000 }] }

Only scripts that call this endpoint directly and read hashes are affected. jazz-tools (fetchSchemaHashes() and the inspector) reads schemas, from beta.0 and alpha.70 servers alike.

Removed: jazz-tools upgrade

The command and its codemods are gone: on beta.0, npx jazz-tools upgrade fails with a message that points here. Its only job was converting an alpha.65 app (s.defineApp, permissions.ts, migrations/index.ts, or a JSON-only app without schema.ts) to alpha.66's schema.ts. Apps on alpha.66 or later don't need it.

An app still on alpha.65 or older: run npx jazz-tools@2.0.0-alpha.70 upgrade, which is still on npm, and review the diff as Upgrading from alpha.65 describes. Then follow the sections from alpha.66 up to here. Without the codemod, that section's step-by-step list is also what to do by hand, or what to give an AI coding assistant.

jazz-tools validate, renamed to generate in alpha.65, is now an unknown command: use npx jazz-tools generate.

For an AI coding assistant

Give it this section and a prompt such as: "Upgrade this app to jazz-tools 2.0.0-beta.0 following the 'Upgrading from alpha.70 to beta.0' section. Replace each removed API with the one it names, then run the typecheck and npx jazz-tools generate, and show me the diff." Review the diff before you deploy.

Upgrading from alpha.68

Local-first auth is called device accounts now, and alpha.69 renames the last names that still said so. Search your app for each name below and replace it. The search patterns are precise, so you, or an AI coding assistant you point at this section, can make every change in one pass.

session.authMode is "device-account" (was "local-first")

A device account's session.authMode is "device-account". Every comparison of session.authMode with "local-first" must change. alpha.69 refuses the old value rather than let the comparison quietly stop matching, since session.authMode != 'local-first' would otherwise start letting device accounts in:

  • jazz-tools generate and validate (and a deployment) refuse it, with the error session.authMode is never "local-first" any more: local-first auth was renamed to device accounts, so compare with "device-account";
  • in schema.ts, eq, ne and isIn with session.authMode and "local-first" are type errors.

Permissions published before alpha.69 stop working on an alpha.69 core. What counts is the version of the core your permissions run on (your self-hosted server, or the Jazz Cloud core), not your backend's. On an alpha.69 core, a policy that still compares session.authMode with "local-first" no longer compiles. Every query whose policy contains that comparison then fails, for every user, signed-in ones included, until you deploy the renamed permissions.

Upgrade the core and redeploy your backend together. On Jazz Cloud you upgrade your app's core separately from your deployment (npx jazz-tools apps upgrade), so the two can be out of step for a while:

  • an alpha.69 core with your old permissions: the tables those policies guard fail for everyone, as above;
  • your new permissions on a core still on alpha.68: eq(session.authMode, "device-account") never matches, which locks device accounts (guests) out, and ne(session.authMode, "device-account") always matches, which lets them in.

To stay correct across that window, check the issuer instead of authMode. It's the same on both versions: eq(session.identity.issuer, "urn:jazz:local-first") holds exactly for a device account (ne(…) for everyone else). Switch to session.authMode once both sides are on alpha.69.

Where to change it. Only where the value is compared with an authMode:

WhereBeforeAfter
schema.ts permissionseq(session.authMode, "local-first")eq(session.authMode, "device-account")
ne(session.authMode, "local-first")ne(session.authMode, "device-account")
isIn(session.authMode, ["external", "local-first"])isIn(session.authMode, ["external", "device-account"])
App codesession.authMode === "local-first" (or !==)session.authMode === "device-account"
case "local-first": in a switch on authModecase "device-account":
Policy testscreatePolicyTestApp(app).as({ authMode: "local-first" }).as({ authMode: "device-account" })

jazz.permissions.json follows from schema.ts when you run generate: don't edit it by hand.

To find them, search for local-first next to authMode, and for case "local-first"::

grep -rnE "authMode.{0,40}local-first|local-first.{0,40}authMode|case ['\"]local-first" \
--include='*.ts' --include='*.tsx' --include='*.js' --include='*.jsx' --include='*.mjs' \
--include='*.svelte' --include='*.vue' . --exclude-dir=node_modules

A search can't find them all: a call your formatter wrapped over several lines, or a value kept in a variable (const mode = "local-first"; … eq(session.authMode, mode)). So after making the changes, run your typecheck and npx jazz-tools generate: the typecheck flags "local-first" compared with an authMode, and generate refuses whatever is left, naming it.

Leave every other "local-first" as it is. These are about where data is stored, not how a session signed in:

  • the read tier tier: "local-first";
  • jazz-tools/local-first and upgradeToLocalFirst;
  • the device-account JWT issuer urn:jazz:local-first and the X-Jazz-Local-First-Audience header;
  • allowLocalFirstAuth;
  • claims you named yourself, such as session.claims.mode = 'local-first'.

Then run npx jazz-tools generate, commit jazz.app.json and jazz.permissions.json, and redeploy your backend. The permissions bundle changes with the new value; the schema hashes don't.

AccountAuthError codes

Three codes are renamed. Replace them wherever your app compares error.code:

BeforeAfter
local_first_account_requireddevice_account_required
local_first_recovery_unavailabledevice_account_recovery_unavailable
local_first_restore_unavailabledevice_account_restore_unavailable

grep -rnE "local_first_(account_required|recovery_unavailable|restore_unavailable)" . finds them. The HTTP error codes local_first_auth_disabled, invalid_local_first_proof and local_first_proof_required are unchanged: leave them.

Renamed APIs (the old names still work)

These old names are deprecated aliases. They keep working, but rename them now so a later release that removes them doesn't break your app:

BeforeAfter
db.getLocalFirstIdentityProof(options)db.getDeviceAccountProof(options) (same options)
type LocalFirstGuest from jazz-tools/backendtype DeviceAccountsAnswer from jazz-tools/backend
jazz-tools apps auth set --allow-local-first-authjazz-tools apps auth set --allow-device-accounts

Look for the CLI flag in package.json scripts, shell scripts and CI workflows. Rename LocalFirstGuest only where it's imported from jazz-tools/backend: a type of your own with that name is unaffected.

For an AI coding assistant

To have an assistant make these changes, give it this section and a prompt such as: "Upgrade this app to jazz-tools alpha.69 following the 'Upgrading from alpha.68' section. Change only the comparisons it lists, leave every other local-first alone, then run npx jazz-tools generate and the typecheck, and show me the diff." Review the diff before you deploy.

Upgrading from alpha.66

  • vercel() takes a required region, the Vercel region its cores run and keep their data in. Earlier versions created every core in iad1: add region: "iad1" and the same cores open with their data. A region that doesn't match an existing core now throws instead of being ignored, since moving a core isn't supported yet. See Region.

Upgrading from alpha.65

alpha.66 keeps your schema in TypeScript, and moves your permissions next to it. schema.ts now exports schema (s.defineSchema({ … })) and permissions (schema.definePermissions({ … })), written in a new permissions DSL. npx jazz-tools generate reads it and writes:

  • jazz.app.json, your tables plus the schema history and migrations your app ships;
  • jazz.permissions.json, your policies;
  • jazz.generated.ts, the typed bindings your app code imports.

The two JSON files are generated: commit them, but don't edit them. generate refuses to overwrite a hand-edited one unless you pass --force. migrations/ keeps its migration files and snapshots; migrations/index.ts is gone. Defining Tables explains how the files fit together. Your queries and writes keep their shape: app.todos.where(…), db.insert(app.todos, …) and the hooks work as before.

Run jazz-tools upgrade and review the diff

Run the upgrade in the app's directory before you bump the dependency, while alpha.65 is still installed, on a clean Git working tree:

npx jazz-tools@2.0.0-alpha.66 upgrade

npx jazz-tools upgrade on its own would run the installed alpha.65, which has no upgrade. Pass --dir <path> for an app elsewhere, --schema-dir <path> when schema.ts isn't in the app's directory, src or src/lib, --dry-run to see everything it would do without writing, and --skip-typecheck to skip the final typecheck.

upgrade:

  1. Runs the installed alpha.65's jazz-tools validate --check, so jazz.app.json and jazz.permissions.json hold exactly your current schema, history and permissions. The new permissions are printed from that file, so a stale one is refused.
  2. Rewrites schema.ts: s.defineApp(schema, { migrations }) becomes export const schema = s.defineSchema({ … }), keeping your comments. Anything else schema.ts exported (constants, type aliases) moves to app-extras.ts; the app and row types now come from jazz.generated.ts.
  3. Prints the permissions from jazz.permissions.json into schema.ts in the new DSL, and deletes permissions.ts. Conditions that repeat become helper functions (isChatMember, rule1, …): rename them, and bring back what the old permissions.ts said in comments or constants. A large permissions.ts (over 150 lines) keeps its own file, rewritten to import schema from ./schema. A tables module schema.ts spreads, such as Better Auth's schema-better-auth/schema.ts, now exports tables and permissions. defs in jazz.permissions.json are expanded where they are called, and the checks they named become helper functions again; the report lists them.
  4. Rewrites imports and code, listing each change as file:line: ./schema becomes ./jazz.generated (and ./app-extras), backends import import permissions from "./jazz.permissions.json" with { type: "json" }, app.slice(…) becomes app, s.RowOf<…> becomes the generated row type, and tsconfig gets resolveJsonModule where needed. package.json scripts that call jazz-tools validate now call jazz-tools generate.
  5. Deletes migrations/index.ts. The migration files and snapshots stay.
  6. Runs generate.
  7. Checks that the schema hashes and the bundle id are the same as before, so the converted app deploys exactly as the old one did. If they differ, or generate fails, it puts every file back byte for byte, bindings included, removes any migrations/ it created, and stops.
  8. Typechecks your .ts and .tsx files, reporting each error as file:line:col. It doesn't roll anything back for these: fix what it reports. For .svelte and .vue files, run svelte-check or vue-tsc yourself.

Then review the diff, commit, and bump jazz-tools (and jazz-napi, if you depend on it) to alpha.66 and reinstall. Things to check in the diff:

  • Helper names. The printed helpers have names upgrade made up. Give them names that say what they check.
  • Left for you. Code upgrade won't convert, such as other files still importing permissions.ts dynamically, is listed at the end.

Apps without schema.ts

An alpha.65 app may have no schema.ts at all: its jazz.app.json and jazz.permissions.json are its source, written by hand or by an agent. upgrade converts it too, with the same command. It doesn't need the app's alpha.65 or typescript installed, since the JSON is what it reads:

  1. It prints schema.ts from the two files: the tables with s.defineSchema, then the permissions in the new DSL. defs are expanded where they are called, and repeated checks become helper functions, named for what they check (isChatMember). A long or vague one gets a placeholder such as rule1: rename it.
  2. It writes migrations/ from the files' history and migrations: a snapshot of each version, the current one included, in migrations/snapshots/, and a migration file for each step.
  3. It runs generate, which writes the two JSON files back from schema.ts (overwriting them, since they have no $generated marker yet) and the bindings for the app's language, such as jazz.generated.ts, or src/jazz_app.rs for a Rust crate on jazz-app-support. It then checks that the schema hashes and the bundle id are the same as before. If they differ, or generate fails, it puts every file back and stops.

It refuses a policy the new DSL can't express (listed by its JSON path), a defs call with the wrong number of arguments, and a schema.ts or migrations/ file that already exists. --dir, --schema-dir (the directory holding jazz.app.json) and --dry-run work as above.

From then on, schema.ts is the source: change it and run generate, rather than editing the JSON. Until the app has a schema.ts, generate and migrations create refuse it and point you here.

What it refuses

Every refusal before generate runs comes before the first write, so your project is left as it was. Each says what to do, with file:line where there is one:

  • Stale files. validate --check failing, or a schema.ts changed since its latest migration snapshot: run alpha.65's npx jazz-tools validate or npx jazz-tools migrations create --name <name> first, commit, then upgrade.
  • The wrong jazz-tools installed: upgrade needs the app's alpha.65 (or older) installed to check the files, and typescript to read schema.ts.
  • Computed fields and transforms in an app with schema.ts, refused with computed columns and transforms is not supported yet by `jazz-tools upgrade` . upgrade doesn't convert them yet: take them out, upgrade, and add them back as in Computed fields and transforms. An app without schema.ts is converted with them.
  • Permissions the new DSL can't express yet, listed with the policy and the reason.
  • Permissions that read the environment, when a policy in jazz.permissions.json is a bare "true" (on its own or inside anyOf/allOf). alpha.65 compiled a condition on an unset variable to true, so the policy may allow more than permissions.ts says. upgrade names each table.operation and each variable read: set those variables and re-run alpha.65's npx jazz-tools validate, or fix permissions.ts, then upgrade again.
  • A schema.ts it can't read: two apps, no s.defineApp(…), no schema import from jazz-tools, or a DSL-built export other files import.
  • Imports it can't rewrite: such as a re-export of anything but permissions.ts's default export.
  • Files it would overwrite: an existing app-extras.ts.

Other permissions that read the environment (process.env.X) aren't refused: the printed policy uses the value alpha.65's validate resolved, under a // TODO comment naming the variable, and the report lists each read under "Left for you". Make the value explicit, or compute it in a helper. defs in an app with schema.ts aren't refused either: step 1 compares what alpha.65 writes with the expanded files by schema hashes and bundle id.

Computed fields and transforms

upgrade refuses an app whose schema.ts has computed fields (s.computed((row) => …)) or column transforms (.transform({ from, to })). Convert them by hand around the upgrade. Neither is stored, so the schema hashes and the bundle id don't change, and upgrade still checks that they don't.

  1. Before upgrading, with alpha.65 still installed, take them out of schema.ts: delete each computed field from the table's second argument, and each column's .transform(…), keeping the stored type (dueAt: s.timestamp().transform(isoDate) becomes dueAt: s.timestamp()). Keep the callbacks aside for step 4. Run alpha.65's npx jazz-tools validate and commit.

  2. Run upgrade as above. Its typecheck reports the code that still uses the removed fields: that's expected until steps 3 to 5 put them back.

  3. In the new schema.ts, declare them in the table's columns:

    • a computed field as s.computed(type, [columns it reads]). It reads stored columns of its table, or "id". An optional result is an optional type, such as s.int().optional();
    • a transformed column as its stored type, then .transform("name", viewType).
    tasks: s.table({
    title: s.string(),
    score: s.int(),
    dueAt: s.timestamp().transform("isoDate", s.string()),
    tags: s.string().transform("tags", s.array(s.string())),
    priority: s.computed(s.enum("low", "medium", "high"), ["score"]),
    label: s.computed(s.string(), ["title", "score"]),
    }),
  4. Put the callbacks in jazz.computed.ts, beside schema.ts. A computed field gets the row, typed with the columns it declared it reads. A transform's from turns the stored value into the one your app sees, and to turns it back. Jazz never calls them with null.

    import type { AppComputed, AppTransforms } from "./jazz.generated";
    ​
    export const computed = {
    tasks: {
    priority: (row) => (row.score >= 8 ? "high" : row.score >= 4 ? "medium" : "low"),
    label: ({ title, score }) => `${title} (${score})`,
    },
    } satisfies AppComputed;
    ​
    export const transforms = {
    isoDate: {
    from: (stored: Date) => stored.toISOString(),
    to: (view: string) => new Date(view),
    },
    tags: { from: (stored: string) => stored.split(","), to: (view: string[]) => view.join(",") },
    } satisfies AppTransforms;
  5. Bump to alpha.66 and run npx jazz-tools generate. jazz.app.json gains the computed fields and transforms, and jazz.generated.ts binds jazz.computed.ts. A missing or extra implementation is a type error naming the field.

Column Types has the details.

Other changes

  • jazz-tools validate is now jazz-tools generate. It reads schema.ts, writes the two JSON files and jazz.generated.ts; generate --check is for CI. validate fails with a message naming the new command.
  • Schema changes start in schema.ts. Edit it, run npx jazz-tools migrations create --name <name>, fill in the migration it writes in migrations/, then run npx jazz-tools generate. See Migrations.
  • Slicing is removed. s.defineSliceableApp and app.slice(…) are gone: the generated module declares every table's types directly, so a large schema no longer needs a smaller typed surface. upgrade rewrites app.slice(…) to app, and a leftover slices key in jazz.app.json loads with a warning.
  • createJazz({ app, permissions }) takes the generated app and the imported jazz.permissions.json, and refuses to start with bindings generated from another jazz.app.json: run npx jazz-tools generate and commit the result.
  • Tests: createPolicyTestApp(app, permissions, expect) takes the same two. See Testing.
  • useSession() (Svelte: getSession()) is deprecated: read useJazzSession().user (Svelte: $session.user with const session = getJazzSession()) instead. Its user (the account ID) is user.accountId; identity and claims keep their names. authMode becomes user?.kind: "backend" for "external", "device" for "local-first", and user === null for "anonymous". In Vue read snapshot.value.user, in Solid snapshot().user. The old hooks still work for this release and warn once.
  • defs are gone from jazz.permissions.json. alpha.66 refuses a file that has them, with a hint to inline each definition or write the app in schema.ts; upgrade does both. In schema.ts, a repeated condition is a plain TypeScript function or constant.
  • Condition objects in the new permissions DSL. An array value means "one of": { role: ["admin", "editor"] } is role in ['admin', 'editor'], and a one-item array such as { role: ["admin"] } is still in. A key whose value is undefined throws: leave the key out, or use null to check for an empty column.
  • Removed: s.defineApp (use s.defineSchema), the callback s.definePermissions and definePermissions(app, …) (use const { definePermissions } = schema), migrations/index.ts, appMigrations, defineShippedApp and { migrations: "none" }. Their names still exist for this release and throw an error pointing to npx jazz-tools upgrade.

Upgrading from alpha.61

The sections from here on describe older releases, in the schema and permissions DSL those releases used: follow them with that release installed, one release at a time, before upgrading to alpha.66.

  • createJazz refuses { migrations: "none" } with a store that keeps its data. An app defined with s.defineApp(schema, { migrations: "none" }) ships no schema history, so a sqlite(), vercel() or remote() store could not follow its first schema change and would refuse the app. createJazz now throws for that combination when it's called, with an error that says what to change. memory() stores, and the test helpers in jazz-tools/testing, still take such an app. To fix it, ship your migrations: pass the module jazz-tools generates beside schema.ts to defineApp,

    schema.ts
    import { migrations } from "./migrations";
    ​
    export const app = s.defineApp(schema, { migrations });

    then run npx jazz-tools migrations create. It records schema.ts as the app's first version and generates migrations/index.ts. Commit the migrations/ directory with your schema. See Shipping migrations with your app.

  • Schema history first. If your app still uses { migrations: "none" }, run npx jazz-tools migrations create on your current, unchanged schema.ts before anything below changes the schema. That snapshot is the first version later migrations start from. Change the schema first and the backend refuses to start (disconnected_migration_graph), which takes the whole app down, sign-in included.

  • vercel() takes a required namespace, which replaces name and decides which core, and so which data, a deployment uses. To keep the cores earlier versions created, use the per-branch setup in Production, previews and development; another namespace starts an empty core.

  • Better Auth 1.7.22. The Better Auth adapter now targets Better Auth ~1.7.22, and better_auth_account loses its required issuer column. Upgrade in this order, after the schema-history step above, and deploy it all in one release:

    1. Upgrade better-auth to 1.7.22 (or a later 1.7.x) and jazz-tools.
    2. Regenerate the auth tables: npx auth@latest generate --config ./auth-generate.ts --output ./schema-better-auth/schema.ts --yes.
    3. Write the migration with npx jazz-tools migrations create --name remove-better-auth-issuer, give the dropped column a backwards default (issuer: m.drop.string({ backwardsDefault: "" })), and run npx jazz-tools validate.
    4. Deploy the backend with the new schema and migration. Better Auth 1.7.3 and later can't create accounts against the old schema, so sign-ups fail until it's published. The adapter refuses to start while your schema still requires issuer, with an error that links here.

    The adapter now also enforces that better_auth_account is unique on (providerId, accountId). Duplicate rows could only exist in a rare setup, where one OIDC providerId was used with several issuers on Better Auth 1.7.0–1.7.2. If account writes (token refreshes, password changes, account links) fail with Unique constraint violated after upgrading, reach out to us rather than deleting rows yourself.

  • React Native: ship a new native build. This release raises the native relay ABI to 6, so a JavaScript bundle needs a native build from the same release; an over-the-air update alone isn't enough.

  • clearOnSignOut in the browser no longer retries in the background. A store left behind by a tab that closed while signed in is wiped when another open page becomes visible or its session changes, or on the next page load. A guest's data is wiped once the device no longer keeps the guest's key (it was linked to a user).

  • A signed-out backend-user answers 200 with { "user": null } instead of 401. Clients read both as signed out; if you alert on its 401s, expect fewer.

Upgrading from alpha.60

Alpha.61 gives a client one auth object, the session, and renames guest accounts to device accounts. Data needs no changes. Backends need two (expiresAt and the recheckSeconds removal, below) and one rename; client code needs more. Your backend still decides who is signed in: after your own sign-in or sign-out, refresh() follows it.

  • authenticate returns expiresAt. A signed-in answer is now { userId, expiresAt, claims? }, where expiresAt is when the user's session ends, in Unix seconds: the session a sign-out ends, not a short-lived access token. A sync connection lasts until then, or sessionTtlSeconds after it opened (one hour by default), whichever comes first, and then authenticates again on a new connection. Without expiresAt, createJazz refuses the answer with an error that says so. See When a session expires.

  • recheckSeconds is removed. Jazz no longer re-checks open connections on a fixed interval; it authenticates again when a connection's session ends. To end a user's connections sooner, for example from your sign-out handler, call await jazz.revokeUser(userId): it ends them on this backend instance, and their clients ask your backend again (and reconnect if it still names the user). Connections on other instances, such as other Vercel functions, end at their deadline. Passing recheckSeconds throws.

  • One session. const session = await createJazzClient(config), or <JazzProvider config={{ … }}> in React, React Native, Expo, Vue, Solid and Svelte. Read it with useJazzSession() (Svelte: getJazzSession()), also in the provider's signedOut, loading and error views. session.db is the signed-in user's Db; it throws while there is none.

  • Device accounts are how you do guests, and a local-first friendly way to sign in: an account whose key lives on the device. See Device Accounts.

  • Errors. A failed operation that leaves the client usable keeps the session ready, with error set. status: "error" now means there is no usable client.

  • window.__jazz is Jazz's page handle, set by every browser client: status(), waitForSync() and clearStorage() for tests and agents. An app that set its own window.__jazz keeps it (Jazz warns once and goes without the handle); rename yours to get the handle.

  • <JazzProvider> refuses the old shapes (the config as its own props, fallback, a config with an account) with an error that names the new one.

Alpha.60Alpha.61
createAccountManager(config) + createDb({ ...config, account })const session = await createJazzClient({ ...config, initial: "device" }); session.db
createDb (jazz-tools, jazz-tools/react-native)createJazzClient(…), then session.db
createJazzApp(config)<JazzProvider config={config}>, or await createJazzClient(config)
<JazzProvider serverUrl="/jazz" …> (config as props)<JazzProvider config={{ serverUrl: "/jazz", … }}>
<JazzProvider client={() => import("jazz-tools/local-first")}><JazzProvider config={{ …, client: () => import("jazz-tools/local-first") }}>
<JazzProvider config={{ …, account }}>, JazzSvelteProvider<JazzProvider config={…}>; a client you opened yourself: <JazzClientProvider client> (Svelte: <JazzSvelteClientProvider client>)
<JazzSessionProvider session={s}><JazzProvider session={s}>
fallbackloading, signedOut, error
useJazzAuth(), useJazzSessionOwner(), useAccountState, accountStateuseJazzSession() (Svelte: getJazzSession())
reauthenticate(), loginWithBackend()refresh()
logout() / dispose()signOut() / close()
createLocalFirst()createDeviceAccount()
restoreLocalFirst(secret)restoreDeviceAccount(key)
linkWithBackend()linkDeviceAccount()
exportLocalFirstSecret(snapshot.account)session.exportDeviceKey()
initial: "local-first"initial: "device"
linkGuestOnSignUplinkDeviceAccountOnSignUp
snapshot.account?.idsnapshot.user?.accountId
user.id (your backend's user ID)user.identity.subject
sessionActions.createLocalFirst() and the other sessionActionsthe same operations on the session itself
useLocalFirstAuth, LocalFirstAuth, BrowserAuthSecretStore, ExpoAuthSecretStore, AuthSecretStoresession.exportDeviceKey() and session.restoreDeviceAccount(key)
acceptLocalFirstAuth (backend)acceptDeviceAccounts
recheckSeconds (backend)removed: connections end at expiresAt or sessionTtlSeconds; jazz.revokeUser(userId) ends them sooner on this instance

snapshot.user is { accountId, kind: "device" | "backend", identity: { issuer, subject }, claims } for whoever is signed in, a device account included, or null. So code that checked user ? <SignOut /> : <SignIn /> now treats a guest on a device account as signed in: to ask whether someone signed in with your auth, check user?.kind === "backend". A client config without serverUrl now means "/jazz" everywhere.

Device accounts kept by useLocalFirstAuth

Device accounts the session already knows open on their own: alpha.61 reads the same account storage. A key that only useLocalFirstAuth, BrowserAuthSecretStore or ExpoAuthSecretStore held, and never reached the account manager, needs moving once, or that user starts with a new device account. Read it where the old store kept it and restore it into the session:

import { authSecretStorageKey, createJazzClient } from "jazz-tools";
​
const session = await createJazzClient({ serverUrl: "/jazz" });
// The key alpha.60's store used: the `key` you gave it, or else this, with its appId and profile.
const legacyKey = authSecretStorageKey({ appId: "your-old-app-id" });
const secret = localStorage.getItem(legacyKey);
if (secret && session.getSnapshot().user?.kind !== "device") {
await session.restoreDeviceAccount(secret);
localStorage.removeItem(legacyKey);
}

On Expo, read the same key with SecureStore.getItemAsync(legacyKey) instead of localStorage.

React Native devices whose store alpha.60 opened without migrations

On alpha.60, a React Native app whose schema had already changed (an app that ships migrations) opened each device's local store without them. Those devices read nothing from your server, and their own writes never uploaded. Alpha.61 fixed this for new stores. From alpha.62 the device repairs an existing one when it can:

  • No unsynced or refused writes: the store is rebuilt from scratch on the first connection and syncs everything again from your server. Nothing is lost, and the app doesn't need to do anything.
  • Writes the server never received: the device keeps them and stays offline: its sync status shows the link { state: "offline", reason: "stopped" }, and lastError.message names StoreOpenedWithoutMigrations. await db.deleteClientStorage() resets the store, and it syncs again, but those writes are lost, along with any the server refused that the app kept for a retry: everything the user created on that device while it couldn't sync. On a device that was affected from its first install, that is everything they created there.

The account itself is never touched: a device account's key lives in the account store (Expo SecureStore, or your own), not in the local store. Don't clear the app's data or reinstall to fix a store: on Android that also deletes SecureStore, and with it a device account.

Upgrading from alpha.59

Upgrade an alpha.59 app in two moves: first to alpha.65, as described below, then from alpha.65 to the current release as in Upgrading from alpha.65. alpha.65 is the last release that ships the alpha.59 exporter and importer, so pin jazz-tools@2.0.0-alpha.65 (and the other Jazz packages at the same version) for the first move.

Alpha.60 changed how Jazz runs, so an alpha.59 app needs more than a version bump:

  • Jazz runs inside your backend. Clients no longer talk to a Jazz server with a JWT. Add a main backend with createJazz (see Your Own Server), and, if your data is on Jazz Cloud (deprecated), have it point there with remote(). The core admits only its own app's backend, so browsers can't connect to it directly any more.
  • Auth moves into authenticate. Your backend decides who each request is. To keep returning users on their old accounts, return the old token's sub as userId (see Custom auth).
  • Clients and backends upgrade together. Alpha.59 clients can't sync with an alpha.60 backend. Ship the new client in the same release as the new backend. A client left on alpha.59 looks healthy: its session reports ready and local writes succeed, but nothing syncs and nothing is logged. Against a createJazz backend, queries and waits that need the server reject with a bare Error: [object Event], and a reloaded alpha.59 tab never signs in. Against Jazz Cloud (deprecated), the first query that waits for the server rejects with "this Jazz client speaks wire protocol 3..=3, older than this server's 6".
  • The storage engine is now SQLite. Alpha.59's data directory doesn't open in alpha.60.

Code changes

Besides moving to createJazz and authenticate, change these before the new backend first starts:

  • Pass your migrations to defineApp, also when your data was imported:

    schema.ts
    import { migrations } from "./migrations";
    ​
    export const app = s.defineApp(schema, { migrations });

    Don't use { migrations: "none" } here: it's only for memory() stores and tests, and createJazz refuses it with any other store. Then run jazz-tools validate. It creates migrations/index.ts if it's missing and moves alpha.59's migrations to migrations/legacy/, and every snapshot except the one matching schema.ts to migrations/legacy/snapshots/. The upgraded app's history starts again from its current schema. If no snapshot matches schema.ts, validate keeps the newest one and tells you to run jazz-tools migrations create before the app starts.

  • Snapshot the current schema before you change it. Run jazz-tools migrations create with no flags while schema.ts still matches what you imported. Later schema changes follow Migrations as usual.

  • Replace isCreator with { $createdBy: session.user }. It compares accounts, so it keeps matching the rows users wrote on alpha.59 whose author was imported with an account.

  • Replace session.user.account with session.user, which is now the account, and session.user.identity with session.identity, in permissions and in client code. Permissions that still use the old form fail with an error saying so; in client code it is silently undefined.

  • Rename removed read tiers. In reads, "global" is now "remote" (ReadTier.Remote), and "local" is "local-first"; "edge" is gone. Write waits keep "local" and "global": wait({ tier: "remote" }) throws. See Removed read tiers.

  • Create accounts for users who never open a client. forReqUser and accountFor no longer create an account. If your API serves users before they sign in from a client, call jazz.createAccountFor(userId) in your sign-in route; see Users without an account.

Data on Jazz Cloud (deprecated)

Jazz Cloud moves your app's data to alpha.60 for you. The move keeps every row with its history, authors and timestamps, your current schema and permissions, and every account. It also links each signed-in user's alpha.59 identity to jazz:backend so authenticate can open their old account.

Self-hosted alpha.59 servers

Move a self-hosted data directory with the alpha.65 exporter and importer, attached to the v2.0.0-alpha.65 release. Later releases don't ship them: the import gives you an alpha.65 data directory, and you upgrade from there. You need only the two downloads below, no Node or Rust toolchain, and nothing writes to your alpha.59 directory.

Before you start:

  • Plan the downtime. It runs from stopping the alpha.59 server until the new backend and the new client bundle are both live, since old clients can't sync with the new backend. The tools themselves take seconds for a small app.
  • Let clients finish syncing, then close them. Writes still queued in an alpha.59 browser, such as ones made offline, are not carried over: alpha.60 opens a new local database and the old one is left unused. Rolling back to alpha.59 is the only way to recover them, so drain open tabs before step 1.
  • Rehearse on a copy if you like. cp -a ./data ./data-rehearsal with the alpha.59 server stopped, then run steps 3 and 4 against the copy; nothing in them writes to it.
  • Make the code changes first, so the new backend can start as soon as the import is verified.
  • Run verify before the new backend's first start. That first start moves large values out of jazz.sqlite into blobs/, and verify can't read the directory after that.

Then:

  1. Stop the alpha.59 server. It drains open connections first, for up to 30 seconds by default (--shutdown-timeout-secs).

  2. Download the tools. Get jazz-alpha59-alpha60-export-<platform> and jazz-alpha59-alpha60-import-<platform> (linux-x64, linux-arm64 or darwin-arm64) and the two checksum files from the v2.0.0-alpha.65 release. Each checksum file lists every platform, so check with --ignore-missing, then rename the tools to drop the platform suffix and make them executable:

    Terminal
    sha256sum -c --ignore-missing jazz-alpha59-alpha60-export.sha256 jazz-alpha59-alpha60-import.sha256
    mv jazz-alpha59-alpha60-export-linux-x64 jazz-alpha59-alpha60-export
    mv jazz-alpha59-alpha60-import-linux-x64 jazz-alpha59-alpha60-import
    chmod +x jazz-alpha59-alpha60-export jazz-alpha59-alpha60-import

    On macOS, use shasum -a 256 -c --ignore-missing and the darwin-arm64 names.

  3. Export the data with alpha.59's own code. --work is an empty scratch directory: the exporter reads a private copy of your data there.

    Terminal
    ./jazz-alpha59-alpha60-export --data-dir ./data --work ./export-work --out app.dump
  4. Import and verify into a new, empty directory. Verify checks every row, sign-in and identity link against what alpha.59 read.

    Terminal
    ./jazz-alpha59-alpha60-import import --dump app.dump --data-dir ./data-new --app-id <appId>
    ./jazz-alpha59-alpha60-import verify --dump app.dump --data-dir ./data-new --app-id <appId>
  5. Start your new backend on alpha.65 with sqlite({ path: "./data-new" }), then deploy the new client, also on alpha.65. If your alpha.59 app had guests on device accounts, pass your old app ID as scope to the client, so each guest's device finds its account again:

    const jazz = await createJazzClient({ scope: "<your alpha.59 app ID>" });

    (<JazzProvider config={{ scope: "…" }}> in React.) With scope set, each guest's browser finds its alpha.59 account by itself, on the same origin; there's nothing else to do. Without it, those guests can't open their accounts. The import prints the exact scope line when it brings guests' device accounts over. If the alpha.59 app was reached through more than one Jazz server URL on that origin, guests aren't picked up automatically. Keep ./data and the dump until you're happy with the result.

  6. Upgrade from alpha.65 to the current release as in Upgrading from alpha.65. The data directory needs nothing more.

--app-id is your app's ID exactly as before, case included: the import uses it to link each returning user's old sign-in to their account, as jazz:backend with their old sub (as fromJWT() returns it), and to keep guests on their device accounts once the client is scoped to the alpha.59 app ID (step 5). The store keeps it in jazz.sqlite, so your code never needs it: sqlite({ path }) runs as the old app. Pass --no-backend-identity-links to skip that. The dump holds all your app's data, so store it like the data directory and delete it when you're done.

The import brings over your current schema and its permissions. A few things alpha.59 could store are not supported yet, and the import stops with an error naming them rather than leaving them out: branched rows, writes the server hadn't settled yet, and rows with no migration path to the current schema. Versions that carry transaction metadata are refused too; pass --drop-transaction-metadata to import them without it. A failed import cleans up after itself.