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 folder | What 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-store | Copies of the identity in jazz.sqlite, kept so an earlier release opened on the directory reads the same one |
inspect-token-secret | A secret: what Inspector agent tokens are signed with (readable by its owner only, never in jazz.sqlite) |
jazz.lock | Held 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-secretas a secret, apart from the data if you like: it signs Inspector agent tokens. Restoringjazz.sqlitewithout 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.sqlitewhile it's being written can give you a copy that doesn't open. -
Copy the
-walfile with the database. It holds recent writes that aren't injazz.sqliteyet. -
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:
- Download the jar (JVM) or the AAR (Android) from the
v2.0.0-beta.1 release into
libs/, and check it against that release'sSHA256SUMS-languages(commands). - Replace the
tools.jazz:dependency with the file and the dependencies it used to bring:
build.gradle.kts// beforeimplementation("tools.jazz:jazz-kotlin:<version>")// afterimplementation(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// beforeimplementation("tools.jazz:jazz-kotlin-android:<version>")// afterimplementation(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")
- 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-toolsand its entry points); - the schema and permissions DSL in
schema.ts, and the migrationsmigrations createwrites; - 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 withvercel(), with its core on another machine throughremote(), or with the core in a Cloudflare Durable Object withdurableObjects()(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 point | Before | After |
|---|---|---|
jazz-tools/react, jazz-tools/react-core, jazz-tools/react-native, jazz-tools/expo | useSession() | useJazzSession().user |
jazz-tools/vue | useSession() | useJazzSession().snapshot.value.user |
jazz-tools/solid | useSession() | useJazzSession().snapshot().user |
jazz-tools/svelte | getSession().current | const session = getJazzSession(), then $session.user |
The fields change too, as in alpha.66:
| Old session | New user |
|---|---|
session.user | user.accountId |
session.identity | user.identity |
session.claims | user.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.
| Removed | Use instead |
|---|---|
useJazzAuth, useJazzSessionOwner, useAccountState, accountState (Svelte) | useJazzSession() (Svelte: getJazzSession()) |
createAccountState, createJazzSessionState | useJazzSession() |
createAccountManager, AccountManager | createJazzClient(config), whose session signs in (initial: "device", createDeviceAccount(), or your backend's user) |
createDb | createJazzClient(config), then session.db |
createJazzApp | createJazzClient(config), or <JazzProvider config={…}> |
exportLocalFirstSecret | session.exportDeviceKey() |
useLocalFirstAuth, createUseLocalFirstAuth, LocalFirstAuth, BrowserAuthSecretStore, ExpoAuthSecretStore, expoAuthSecretStore | device 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.
| Before | After |
|---|---|
db.getLocalFirstIdentityProof(options) | db.getDeviceAccountProof(options) (same options, same token) |
type LocalFirstGuest from jazz-tools/backend | type 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.
| Removed | Use instead |
|---|---|
defineApp | s.defineSchema({ … }) in schema.ts; runtime code imports app from ./jazz.generated |
root defineSchema, table | s.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, renameTableFrom | m.defineMigration, m.renameTableFrom (import { migration as m } from "jazz-tools") |
defineSliceableApp, schemaToWasm | nothing: slicing is gone, and jazz.generated.ts embeds the compiled schema |
schema, migration from jazz-tools/react-native | write 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:
| Before | After |
|---|---|
identity::LOCAL_FIRST_ISSUER, AuthorSubject::LOCAL_FIRST_ISSUER | DEVICE_ACCOUNT_ISSUER |
sign_local_first_challenge, verify_local_first_challenge | sign_device_account_challenge, verify_device_account_challenge |
local_first_account_id | device_account_id |
Binding::admit_local_first_session | admit_device_account_session |
admitted_local_first_accounts (testing only) | admitted_device_accounts |
jazz-server: LOCAL_FIRST_JWT_ISSUER, admit_local_first_jwt | DEVICE_ACCOUNT_JWT_ISSUER, admit_device_account_jwt |
jazz-server: LOCAL_FIRST_AUDIENCE_HEADER | DEVICE_ACCOUNT_AUDIENCE_HEADER |
jazz-server: local_first_audience, local_first_founding_app | device_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 generateandvalidate(and a deployment) refuse it, with the errorsession.authMode is never "local-first" any more: local-first auth was renamed to device accounts, so compare with "device-account";- in
schema.ts,eq,neandisInwithsession.authModeand"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, andne(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:
| Where | Before | After |
|---|---|---|
schema.ts permissions | eq(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 code | session.authMode === "local-first" (or !==) | session.authMode === "device-account" |
case "local-first": in a switch on authMode | case "device-account": | |
| Policy tests | createPolicyTestApp(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-firstandupgradeToLocalFirst;- the device-account JWT issuer
urn:jazz:local-firstand theX-Jazz-Local-First-Audienceheader; 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:
| Before | After |
|---|---|
local_first_account_required | device_account_required |
local_first_recovery_unavailable | device_account_recovery_unavailable |
local_first_restore_unavailable | device_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:
| Before | After |
|---|---|
db.getLocalFirstIdentityProof(options) | db.getDeviceAccountProof(options) (same options) |
type LocalFirstGuest from jazz-tools/backend | type DeviceAccountsAnswer from jazz-tools/backend |
jazz-tools apps auth set --allow-local-first-auth | jazz-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 requiredregion, the Vercel region its cores run and keep their data in. Earlier versions created every core iniad1: addregion: "iad1"and the same cores open with their data. Aregionthat 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:
- Runs the installed alpha.65's
jazz-tools validate --check, sojazz.app.jsonandjazz.permissions.jsonhold exactly your current schema, history and permissions. The new permissions are printed from that file, so a stale one is refused. - Rewrites
schema.ts:s.defineApp(schema, { migrations })becomesexport const schema = s.defineSchema({ … }), keeping your comments. Anything elseschema.tsexported (constants, type aliases) moves toapp-extras.ts; the app and row types now come fromjazz.generated.ts. - Prints the permissions from
jazz.permissions.jsonintoschema.tsin the new DSL, and deletespermissions.ts. Conditions that repeat become helper functions (isChatMember,rule1, …): rename them, and bring back what the oldpermissions.tssaid in comments or constants. A largepermissions.ts(over 150 lines) keeps its own file, rewritten to importschemafrom./schema. A tables moduleschema.tsspreads, such as Better Auth'sschema-better-auth/schema.ts, now exportstablesandpermissions.defsinjazz.permissions.jsonare expanded where they are called, and the checks they named become helper functions again; the report lists them. - Rewrites imports and code, listing each change as
file:line:./schemabecomes./jazz.generated(and./app-extras), backends importimport permissions from "./jazz.permissions.json" with { type: "json" },app.slice(…)becomesapp,s.RowOf<…>becomes the generated row type, and tsconfig getsresolveJsonModulewhere needed.package.jsonscripts that calljazz-tools validatenow calljazz-tools generate. - Deletes
migrations/index.ts. The migration files and snapshots stay. - Runs
generate. - 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
generatefails, it puts every file back byte for byte, bindings included, removes anymigrations/it created, and stops. - Typechecks your
.tsand.tsxfiles, reporting each error asfile:line:col. It doesn't roll anything back for these: fix what it reports. For.svelteand.vuefiles, runsvelte-checkorvue-tscyourself.
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
upgrademade up. Give them names that say what they check. - Left for you. Code
upgradewon't convert, such as other files still importingpermissions.tsdynamically, 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:
- It prints
schema.tsfrom the two files: the tables withs.defineSchema, then the permissions in the new DSL.defsare 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 asrule1: rename it. - It writes
migrations/from the files'historyandmigrations: a snapshot of each version, the current one included, inmigrations/snapshots/, and a migration file for each step. - It runs
generate, which writes the two JSON files back fromschema.ts(overwriting them, since they have no$generatedmarker yet) and the bindings for the app's language, such asjazz.generated.ts, orsrc/jazz_app.rsfor a Rust crate onjazz-app-support. It then checks that the schema hashes and the bundle id are the same as before. If they differ, orgeneratefails, 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 --checkfailing, or aschema.tschanged since its latest migration snapshot: run alpha.65'snpx jazz-tools validateornpx jazz-tools migrations create --name <name>first, commit, then upgrade. - The wrong
jazz-toolsinstalled:upgradeneeds the app's alpha.65 (or older) installed to check the files, andtypescriptto readschema.ts. - Computed fields and transforms in an app with
schema.ts, refused withcomputed columns and transforms is not supported yet by `jazz-tools upgrade`.upgradedoesn't convert them yet: take them out, upgrade, and add them back as in Computed fields and transforms. An app withoutschema.tsis 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.jsonis a bare"true"(on its own or insideanyOf/allOf). alpha.65 compiled a condition on an unset variable totrue, so the policy may allow more thanpermissions.tssays.upgradenames eachtable.operationand each variable read: set those variables and re-run alpha.65'snpx jazz-tools validate, or fixpermissions.ts, then upgrade again. - A
schema.tsit can't read: two apps, nos.defineApp(…), noschemaimport fromjazz-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.
-
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)becomesdueAt: s.timestamp()). Keep the callbacks aside for step 4. Run alpha.65'snpx jazz-tools validateand commit. -
Run
upgradeas above. Its typecheck reports the code that still uses the removed fields: that's expected until steps 3 to 5 put them back. -
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 ass.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"]),}), - a computed field as
-
Put the callbacks in
jazz.computed.ts, besideschema.ts. A computed field gets the row, typed with the columns it declared it reads. A transform'sfromturns the stored value into the one your app sees, andtoturns it back. Jazz never calls them withnull.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; -
Bump to alpha.66 and run
npx jazz-tools generate.jazz.app.jsongains thecomputedfields andtransforms, andjazz.generated.tsbindsjazz.computed.ts. A missing or extra implementation is a type error naming the field.
Column Types has the details.
Other changes
jazz-tools validateis nowjazz-tools generate. It readsschema.ts, writes the two JSON files andjazz.generated.ts;generate --checkis for CI.validatefails with a message naming the new command.- Schema changes start in
schema.ts. Edit it, runnpx jazz-tools migrations create --name <name>, fill in the migration it writes inmigrations/, then runnpx jazz-tools generate. See Migrations. - Slicing is removed.
s.defineSliceableAppandapp.slice(…)are gone: the generated module declares every table's types directly, so a large schema no longer needs a smaller typed surface.upgraderewritesapp.slice(…)toapp, and a leftoversliceskey injazz.app.jsonloads with a warning. createJazz({ app, permissions })takes the generatedappand the importedjazz.permissions.json, and refuses to start with bindings generated from anotherjazz.app.json: runnpx jazz-tools generateand commit the result.- Tests:
createPolicyTestApp(app, permissions, expect)takes the same two. See Testing. useSession()(Svelte:getSession()) is deprecated: readuseJazzSession().user(Svelte:$session.userwithconst session = getJazzSession()) instead. Itsuser(the account ID) isuser.accountId;identityandclaimskeep their names.authModebecomesuser?.kind:"backend"for"external","device"for"local-first", anduser === nullfor"anonymous". In Vue readsnapshot.value.user, in Solidsnapshot().user. The old hooks still work for this release and warn once.defsare gone fromjazz.permissions.json. alpha.66 refuses a file that has them, with a hint to inline each definition or write the app inschema.ts;upgradedoes both. Inschema.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"] }isrole in ['admin', 'editor'], and a one-item array such as{ role: ["admin"] }is stillin. A key whose value isundefinedthrows: leave the key out, or usenullto check for an empty column. - Removed:
s.defineApp(uses.defineSchema), the callbacks.definePermissionsanddefinePermissions(app, …)(useconst { definePermissions } = schema),migrations/index.ts,appMigrations,defineShippedAppand{ migrations: "none" }. Their names still exist for this release and throw an error pointing tonpx 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.
-
createJazzrefuses{ migrations: "none" }with a store that keeps its data. An app defined withs.defineApp(schema, { migrations: "none" })ships no schema history, so asqlite(),vercel()orremote()store could not follow its first schema change and would refuse the app.createJazznow throws for that combination when it's called, with an error that says what to change.memory()stores, and the test helpers injazz-tools/testing, still take such an app. To fix it, ship your migrations: pass the modulejazz-toolsgenerates besideschema.tstodefineApp,schema.tsimport { migrations } from "./migrations";export const app = s.defineApp(schema, { migrations });then run
npx jazz-tools migrations create. It recordsschema.tsas the app's first version and generatesmigrations/index.ts. Commit themigrations/directory with your schema. See Shipping migrations with your app. -
Schema history first. If your app still uses
{ migrations: "none" }, runnpx jazz-tools migrations createon your current, unchangedschema.tsbefore 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 requirednamespace, which replacesnameand 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, andbetter_auth_accountloses its requiredissuercolumn. Upgrade in this order, after the schema-history step above, and deploy it all in one release:- Upgrade
better-authto 1.7.22 (or a later 1.7.x) andjazz-tools. - Regenerate the auth tables:
npx auth@latest generate --config ./auth-generate.ts --output ./schema-better-auth/schema.ts --yes. - 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 runnpx jazz-tools validate. - 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_accountis unique on(providerId, accountId). Duplicate rows could only exist in a rare setup, where one OIDCproviderIdwas used with several issuers on Better Auth 1.7.0–1.7.2. If account writes (token refreshes, password changes, account links) fail withUnique constraint violatedafter upgrading, reach out to us rather than deleting rows yourself. - Upgrade
-
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.
-
clearOnSignOutin 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-useranswers 200 with{ "user": null }instead of401. 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.
-
authenticatereturnsexpiresAt. A signed-in answer is now{ userId, expiresAt, claims? }, whereexpiresAtis 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, orsessionTtlSecondsafter it opened (one hour by default), whichever comes first, and then authenticates again on a new connection. WithoutexpiresAt,createJazzrefuses the answer with an error that says so. See When a session expires. -
recheckSecondsis 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, callawait 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. PassingrecheckSecondsthrows. -
One session.
const session = await createJazzClient(config), or<JazzProvider config={{ … }}>in React, React Native, Expo, Vue, Solid and Svelte. Read it withuseJazzSession()(Svelte:getJazzSession()), also in the provider'ssignedOut,loadinganderrorviews.session.dbis 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, witherrorset.status: "error"now means there is no usable client. -
window.__jazzis Jazz's page handle, set by every browser client:status(),waitForSync()andclearStorage()for tests and agents. An app that set its ownwindow.__jazzkeeps 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 anaccount) with an error that names the new one.
| Alpha.60 | Alpha.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}> |
fallback | loading, signedOut, error |
useJazzAuth(), useJazzSessionOwner(), useAccountState, accountState | useJazzSession() (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" |
linkGuestOnSignUp | linkDeviceAccountOnSignUp |
snapshot.account?.id | snapshot.user?.accountId |
user.id (your backend's user ID) | user.identity.subject |
sessionActions.createLocalFirst() and the other sessionActions | the same operations on the session itself |
useLocalFirstAuth, LocalFirstAuth, BrowserAuthSecretStore, ExpoAuthSecretStore, AuthSecretStore | session.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" }, andlastError.messagenamesStoreOpenedWithoutMigrations.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 withremote(). 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'ssubasuserId(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
createJazzbackend, queries and waits that need the server reject with a bareError: [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.tsimport { migrations } from "./migrations";export const app = s.defineApp(schema, { migrations });Don't use
{ migrations: "none" }here: it's only formemory()stores and tests, andcreateJazzrefuses it with any other store. Then runjazz-tools validate. It createsmigrations/index.tsif it's missing and moves alpha.59's migrations tomigrations/legacy/, and every snapshot except the one matchingschema.tstomigrations/legacy/snapshots/. The upgraded app's history starts again from its current schema. If no snapshot matchesschema.ts, validate keeps the newest one and tells you to runjazz-tools migrations createbefore the app starts. -
Snapshot the current schema before you change it. Run
jazz-tools migrations createwith no flags whileschema.tsstill matches what you imported. Later schema changes follow Migrations as usual. -
Replace
isCreatorwith{ $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.accountwithsession.user, which is now the account, andsession.user.identitywithsession.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 silentlyundefined. -
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.
forReqUserandaccountForno longer create an account. If your API serves users before they sign in from a client, calljazz.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-rehearsalwith 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
verifybefore the new backend's first start. That first start moves large values out ofjazz.sqliteintoblobs/, andverifycan't read the directory after that.
Then:
-
Stop the alpha.59 server. It drains open connections first, for up to 30 seconds by default (
--shutdown-timeout-secs). -
Download the tools. Get
jazz-alpha59-alpha60-export-<platform>andjazz-alpha59-alpha60-import-<platform>(linux-x64,linux-arm64ordarwin-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:Terminalsha256sum -c --ignore-missing jazz-alpha59-alpha60-export.sha256 jazz-alpha59-alpha60-import.sha256mv jazz-alpha59-alpha60-export-linux-x64 jazz-alpha59-alpha60-exportmv jazz-alpha59-alpha60-import-linux-x64 jazz-alpha59-alpha60-importchmod +x jazz-alpha59-alpha60-export jazz-alpha59-alpha60-importOn macOS, use
shasum -a 256 -c --ignore-missingand thedarwin-arm64names. -
Export the data with alpha.59's own code.
--workis 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 -
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> -
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 asscopeto 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.) Withscopeset, 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 exactscopeline 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./dataand the dump until you're happy with the result. -
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.