The sessions CLI
One command for the whole loop — sign in, type your GraphQL, bundle, push a version, publish it — installed with @sessions/apps.
Install and sign in
@sessions/apps is the only development dependency an app needs; it provides the sessions command. Node 22.18 or later.
It is published as git tags of the Sessions repository, so install an exact tag with the git credentials you clone the repository with. There are no semver ranges: upgrading is changing the tag.
sessions login opens your browser on Sessions; authorize the CLI there and it stores a developer token in ~/.sessions/credentials.json for this machine.
# @sessions/apps is published as git tags of the Sessions repository.
# Pin an exact tag; anyone who can clone the repository can install it.
npm install --save-dev github:SessionsCode/Sessions#sessions-apps/v0.1.0 preact
npx sessions login{
"name": "studio-notes",
"private": true,
"type": "module",
"scripts": {
"types": "sessions types",
"build": "sessions build",
"push": "sessions push",
"publish:app": "sessions publish"
},
"devDependencies": {
"@sessions/apps": "github:SessionsCode/Sessions#sessions-apps/v0.1.0",
"preact": "^10.29.0"
}
}Project layout
An app is a directory with a sessions.app.json at its root and one directory per extension under extensions/, each with a sessions.extension.json, one module per target, its .graphql documents and its translations.
handlename · descriptioniconsessions push whenever it changes.extensionssessions.extension.json. Defaults to extensions/*.handlename · descriptiontargets[].targetbusiness.session.details.block or public.session.detail-list.row.targets[].moduletargets[].query.graphql file with the target’s live query. Optional.*.graphqltranslations/<locale>.jsonen.json, fr.json, fr-CA.json). Pushed with every version.sessions build bundles each on its own, so buyers only ever download your public target’s code.studio-notes/
├── package.json
├── sessions.app.json
├── assets/
│ └── icon.png ← the app icon, uploaded on push
└── extensions/
└── session-note/
├── sessions.extension.json
├── SessionNoteQuery.graphql ← the live query
├── SaveNoteMutation.graphql ← a mutation, imported by business.tsx
├── *.graphql.d.ts ← written by `sessions types`
├── business.tsx ← business.session.details.block
├── public.tsx ← public.session.detail-list.row
└── translations/
├── en.json
└── fr.jsonCommands
sessions loginsessions logoutsessions whoamisessions types.graphql document against the extension API and write a *.graphql.d.ts beside each. build and push run it first.sessions build.sessions/build/<extension>/<target>.js without uploading.sessions pushsessions push --publishsessions publish$ npx sessions build
Built 1 extension
– session-note · business.session.details.block → .sessions/build/session-note/business.session.details.block.js
– session-note · public.session.detail-list.row → .sessions/build/session-note/public.session.detail-list.row.jsGraphQL documents and types
Write each GraphQL operation in its own .graphql file. The live query is named by query in sessions.extension.json; a mutation is imported by the module that runs it — import saveNote from './SaveNoteMutation.graphql' — and passed to api.mutate(saveNote, {variables}).
Every build validates every document against the extension API, and a mistake stops the build with the file, line and column.
sessions types writes a *.graphql.d.ts beside each document: <Name>QueryData or <Name>MutationData, …Variables, and a typed default export. api.mutate then checks your variables and types result.data, and useQuery<SessionNoteQueryData>() needs no hand-written interface. The files are generated — git-ignore *.graphql.d.ts, and set allowArbitraryExtensions in tsconfig.json.
public.*) target is read-only: the build refuses a mutation that ends up in its module.mutation SaveNote($owner: EntityRef!, $value: String!) {
setMetadata(owner: $owner, name: "app.studio-notes.note", value: $value) {
value
errors {
message
}
}
}$ npx sessions build
✖ extensions/session-note/SaveNoteMutation.graphql:2:3: Cannot query field "setMetadatas" on type "Mutation". Did you mean "setMetadata"?Translations
Put one translations/<locale>.json per language in the extension directory — en.json, fr.json, es.json, or a regional fr-CA.json. sessions push sends them with the version, and the module reads them with api.localization.translate(key).
Values are strings or nested objects, up to 256 KB in all. A key is a dot path into them; {{name}} is a placeholder; an object keyed one / other (and the other Intl.PluralRules categories) is a plural, chosen by the count replacement. English is the fallback, so ship en.json.
{
"label": "Note for {{activity}}",
"save": "Save note",
"saved": "Note saved",
"saveFailed": "Couldn’t save the note",
"fromTheDesk": "From the front desk"
}App icon
Name your icon with "icon": "./assets/icon.png" in sessions.app.json — a square PNG, JPEG or WebP, at least 512×512 and up to 5 MB. sessions push uploads it when the file has changed since the last upload from this project (it keeps a hash in .sessions/state.json).
The icon heads each of your extension cards, and your app’s row and page in a business’s Apps settings. Draw it edge to edge: Sessions rounds the corners.
Authentication and CI
The CLI acts as you, with a developer token minted by the authorize page. It can push to apps you own and nothing else. Revoke a token any time with sessions logout.
In CI, skip the browser: mint a token once with sessions login on your machine, copy it from ~/.sessions/credentials.json into a secret, and set it as an environment variable.
SESSIONS_ACCESS_TOKENSESSIONS_API_URLhttps://go.sessions.website).# .github/workflows/publish.yml
- run: npm ci
- run: npx sessions push --publish
env:
SESSIONS_ACCESS_TOKEN: ${{ secrets.SESSIONS_ACCESS_TOKEN }}Installing your app
Once an extension is published, open a business’s Settings, then Apps, and install the app by its handle. Its extensions render immediately.
While an app is private, only its owner can install it — into businesses they are on the staff of. That is how you test against real data before anyone else sees it.
The business stays in charge: from an extension card’s “…” menu, or the app’s page at /settings/apps/<handle>, an admin can hide one extension or uninstall the app.