---
title: Manifest
description: Everything a plugin declares up front, the services, accounts, preferences, pages and synced data, and what the host builds from each.
---

`defineManifest` takes data only. The host reads it without running plugin code, validates it when the plugin loads, and derives the settings page, health chips, keychain entries and routes from it.

```ts
defineManifest({
  id: 'podcasts',          // lowercase, dashes: also the route prefix /p/podcasts
  name: 'Podcasts',        // settings and sidebar label
  sources: undefined,      // optional: the web video namespaces it owns, see Sources
  native: undefined,       // a compiled-in Tauri plugin, see Native half
  capabilities: undefined, // optional: what it reads on this Mac and whose faces it names, see Capabilities
  services: { /* … */ },
  preferences: { /* … */ },
  pages: { /* … */ },      // optional
  collections: { /* … */ },// optional
})
```

Keys in `services`, `preferences`, `pages` and `collections` are camelCase identifiers. They become keychain names (`account_<key>`, `pref_<name>`), health ids (`<plugin>/<key>`) and route segments.

## Translations

Keep the plugin’s translations in JSON files next to its source and import them into its manifest. Use canonical language tags such as `fr`, `ar`, and `pt-BR`.

```ts manifest.ts
import { defineManifest, field } from '@playactor/plugin/manifest'
import fr from './locales/fr.json'

export const manifest = defineManifest({
  id: 'streams',
  name: 'Streams',
  translations: { fr },
  services: {},
  preferences: {
    language: field.select({
      title: 'Stream language',
      options: [{ value: 'all', title: 'All languages' }],
      default: 'all',
    }),
  },
})
```

```json locales/fr.json
{
  "Streams": "Diffusions",
  "Stream language": "Langue des diffusions",
  "All languages": "Toutes les langues"
}
```

Playactor translates the plugin name, sidebar page titles, preference labels, select options, and sign-in fields from its `plugin:<id>` namespace. Settings search finds both the English and translated labels. Option values, keys, and route IDs stay the same in every language. The CLI reads the sidebar list from the plugin entry's `area.pages`. Only those page titles enter the catalog from the manifest. When the sidebar lists `home`, its label is `Home`.

Run `playactor plugin i18n` from the plugin's directory. It collects the manifest's labels and the English phrases in your source, generates `src/messages.gen.ts`, and adds blank entries to your catalogs for you to translate. To add a locale, create an empty JSON object in `src/locales/<lang>.json` and import it into `manifest.translations`. Use `playactor plugin i18n --check` to catch stale types, missing or extra entries, and mismatched placeholders. Use `--prune` during generation to remove unused entries.

```tsx
import { phrase, usePluginText } from '@playactor/plugin'
import { manifest } from './manifest'
import type { Messages } from './messages.gen'

const languages = [{ value: 'en', title: phrase('English') }]

function LanguageLabel({ count }: { count: number }) {
  const t = usePluginText<Messages>(manifest)
  return (
    <div>
      {t('Stream language')}
      {languages.map(language => (
        <span key={language.value}>{t.label(language.title)}</span>
      ))}
      {t('{{count}} viewers', { count })}
      {t('Live', { context: 'stream' })}
    </div>
  )
}
```

Use a literal English phrase for a message. Use `phrase()` to declare a label in a table and `t.label()` to render it. TypeScript checks the phrase and values against `Messages`. Placeholders use `{{identifier}}` and take strings or numbers. The name `context` is reserved for the selector. The special placeholder `{{count}}` takes a number and selects a plural form.

Catalog plural keys end in the locale's plural category, such as `{{count}} viewers_one` and `{{count}} viewers_other` in French. Keep `{{count}}` in each translation and supply every category required by that locale's `Intl.PluralRules`. With plurals, also import the generated `src/locales/en.json` into `translations` and fill in its English forms.

To show a count compactly (`1.2K viewers`), use `formatCount` from `@playactor/ui/lib/format`. In some languages the abbreviated number decides the noun's form, not the count. Russian writes `1 тыс. зрителей` for 1,001, but `{{count}}` would pick the singular form for 1,001. So an abbreviated number gets a `{{number}}` phrase of its own:

```ts
import { formatCount } from '@playactor/ui/lib/format'

formatCount(stream.viewers, language, {
  full: count => t('{{count}} viewers', { count }),
  abbreviated: number => t('{{number}} viewers', { number }),
}) // null when the count is unknown
```

For ambiguous words, declare a literal `context` in the inline values object. For `t('Live', { context: 'stream' })`, translated catalogs contain both `Live` and `Live_stream`. For a plural with context, the context precedes the plural suffix. Playactor follows the active language and its fallbacks and uses the English phrase when no catalog entry is available.

## Services

A service is one remote the plugin talks to. Every request through it, and every redirect hop, stays on its `hosts` over HTTPS.

```ts
services: {
  pocketcasts: {
    title: 'Pocket Casts',
    hosts: ['api.pocketcasts.com', 'podcast-api.pocketcasts.com'],
    account: login({ /* … */ }),
  },
  filmmap: {
    title: 'Film map',
    hosts: ['clipt-filmmap.methodactor.workers.dev'],
  },
},
```

| Field | Meaning |
| --- | --- |
| `title` | Shown on the health chip and the settings row. |
| `hosts` | The only hosts the service's fetch and sockets reach (`*.example.com` for a domain's subdomains). Without it, the service makes no web requests. |
| `account` | What the user signs in with. One of `login(…)`, `oauth.redirect(…)`, `oauth.device(…)`, `oauth.google(…)` or `native(…)`. |
| `credential` | The password preference the service can't work without. Until it's set, the service reads as not set up and links to settings. A service has an `account` or a `credential`, not both. |
| `guard: 'vpn'` | The plugin runs only while the VPN is up, its native half included. Needs `native`. `vpn` is the only guard. |

Each service gets a health chip. A chip's Fix link opens the plugin's settings.

## Permissions

The host lists what a plugin can reach, derived from its manifest by `permissionsOf` (`@playactor/plugin`). There's no second list to keep in step. The lines show on the dialog that adds a plugin and in its section of Settings › Plugins, built-ins included.

| Declaration | What the user sees |
| --- | --- |
| A host in any service's `hosts` | **Talks to api.pocketcasts.com**, once per host across services |
| A `*.` host | **Talks to archive.org subdomains** |
| `account: oauth.redirect(…)` or `oauth.device(…)` | **Signs in at accounts.spotify.com**, the host of the page the sign-in opens; **Signs in at a.example and b.example** when the token endpoint is on another host |
| `account: oauth.google(…)` | **Signs in to Google** |
| `account: login(…)` or `native(…)` | **Signs in to Pocket Casts**, the service's `title` |
| A file in `capabilities.sqlite.read` | **Reads the database Photos.sqlite**, its name |
| A folder in `capabilities.files.read` | **Reads files in Photos Library**, its name without the extension |
| `capabilities.faces` | **Finds and names your home people in its files** |
| `capabilities.contacts` | **Reads names and photos in Contacts** |
| `native` | **Runs native code built into Playactor** |

`collections` aren't permissions: they're the plugin's own data, and the dialog lists them on their own row. What every plugin can do through `api.app` (add to Home, start downloads, toast, navigate) isn't listed, because no manifest declares it.

The list you approve is kept beside the plugin's pin. A feed release that asks for more is held back until you review it; see [Held back](/docs/plugins/external#held-back). A host already covered by an approved `*.` host isn't new. A `*.` host is new unless the same one, or a wider one, was approved. `*.archive.org` never covers `archive.org` itself. A folder under an approved folder isn't new; a database is new unless that same file was approved, and `faces` and `contacts` are each new unless approved before.

## Capabilities

What the plugin reads on this Mac, through [`api.local`](/docs/plugins/api#apilocal) (databases, files and Contacts), and whose faces it names, through [`api.faces`](/docs/plugins/api#apifaces). `sqlite` and `files` are lists of paths, absolute or starting with `~/`:

```ts
capabilities: {
  sqlite: {
    read: ['~/Pictures/Photos Library.photoslibrary/database/Photos.sqlite'], // this file, exactly
  },
  files: { read: ['~/Pictures/Photos Library.photoslibrary'] },            // this folder and under it
  faces: { people: 'home' },                                               // api.faces, in those files
  contacts: { read: true },                                                // api.local.contacts: names and photos, by handle
},
```

| Field | Meaning |
| --- | --- |
| `sqlite.read` | Databases `api.local.sqlite` opens read-only, each this exact file. |
| `files.read` | Folders `api.local.files.urls` gives URLs in, `api.local.files.poster` makes posters of and `api.app.library.add` copies from, each the folder and everything under it, compared by whole names. |
| `faces.people` | `'home'`: `api.faces` finds faces in files under `files.read` and names them as home people. Needs `files`. |
| `contacts.read` | `true`: `api.local.contacts.lookup` answers who a phone number or email belongs to in Contacts. macOS asks for Contacts access the first time. |

Each path, `faces` and `contacts` show under Permissions. A path with `..` in it, a relative path, an empty list, `faces` without `files`, and a kind other than `sqlite`, `files`, `faces` and `contacts` don't load. Paths resolve on every call with symlinks followed, so a link inside a folder that points out of it stays out.

## Accounts

### Sign-in form

The host renders the form and passes the values to the plugin's `connect`, which exchanges them for tokens. The values are never stored; the tokens go to the keychain.

```ts manifest.ts
account: login({
  email: field.text({ title: 'Email', type: 'email' }),
  password: field.password({ title: 'Password' }),
}),
```

```ts index.ts
definePlugin(manifest, {
  accounts: {
    pocketcasts: {
      connect: (fetch, { email, password }) => pocketCastsAuth(fetch).login(email, password),
      refresh: (fetch, refreshToken) => pocketCastsAuth(fetch).refresh(refreshToken),
    },
  },
  // …
})
```

`connect` and `refresh` return `{ accessToken, refreshToken? }`. On a 401 or 403 the host calls `refresh` once and retries. A 401/403 from `connect` shows "Wrong email or password"; anything else shows "Couldn't reach Pocket Casts".

### OAuth

The plugin carries its own OAuth client: the client id and endpoints of an app you registered with the provider. The host runs consent in the system browser, stores the refresh token in the keychain and refreshes it; plugin code never sees a token. A provider whose token never expires and comes with no refresh token (itch.io) is kept the same way, the token itself in the keychain until the user disconnects. The client is a public one, so there's no secret field: register the app as a public or PKCE client.

`oauth.redirect` signs in with PKCE over a redirect back to the app:

```ts
account: oauth.redirect({
  clientId: 'bec6dec0cf61491f91e02a5041f7958c',
  authorize: 'https://accounts.spotify.com/authorize',
  token: 'https://accounts.spotify.com/api/token',
  port: 53817,
  scopes: ['playlist-modify-private', 'playlist-read-private'],
}),
```

| Field | Meaning |
| --- | --- |
| `clientId` | The app's client id at the provider. |
| `authorize` | The consent page, `https://` only. |
| `token` | The token endpoint, `https://` only: the code exchange and every refresh. |
| `port` | The redirect is `http://127.0.0.1:<port>/callback`. Set it when the provider wants the exact URI registered, to 1024 or above. Leave it out when the provider accepts any port on `127.0.0.1` (register `http://127.0.0.1/callback`): the host takes a free one, so sign-in never fails on a port another app holds. |
| `params` | Extra query parameters for the consent page, such as `{ access_type: 'offline' }`. The host sets `response_type`, `client_id`, `redirect_uri`, `scope`, `state`, `code_challenge` and `code_challenge_method` itself; a manifest naming one of them is refused. |
| `clientIdHeader` | A header name. The service's requests carry the client id in it beside the token. |
| `scopes` | What to ask for. |

`oauth.device` signs in with a device code (RFC 8628), for providers that give a public client nothing else: the host opens the provider's activation page with the code filled in and waits up to five minutes for the person to approve. It takes `device`, the device authorization endpoint, in place of `authorize`, and has no `port` or `params`:

```ts
account: oauth.device({
  clientId: 'u1shwysfcvpo9yvy7cje4jx1y5ztli',
  device: 'https://id.twitch.tv/oauth2/device',
  token: 'https://id.twitch.tv/oauth2/token',
  clientIdHeader: 'Client-Id', // Twitch's API wants it on every request
  scopes: ['user:read:follows'],
}),
```

A change to `port`, `authorize`, `device` or `params` ships as a plugin release and keeps everyone signed in. A grant belongs to one `clientId` at one `token` endpoint: change either and existing users see **Reconnect**, and the old refresh token is never sent to the new endpoint.

`oauth.google({ scopes })` is the one registration the host owns, because Google's desktop clients need a secret from the app's build. Every other provider is a client the plugin declares with `oauth.redirect` or `oauth.device`.

The host stores the scopes the provider actually granted beside the grant. The account counts as connected only while those cover every scope the manifest asks for. Add a scope in a new version and existing users see **Reconnect** in the plugin's settings, and its service's status reads **Reconnect needed**; until they sign in again, `useAccount` reads `{ connected: false }` and their old grant stays in place. Gate a feature that needs the new scope on `connected`:

```ts
const { connected } = useAccount(api.services.twitch.account)
<Player source={stream} side={connected ? <Chat api={api} /> : null} />
```

An optional `label` shows who is signed in on the settings row:

```ts
accounts: {
  youtube: { label: async fetch => (await createYouTubeClient({ fetch }).mine())?.title ?? null },
},
```

### Native sign-in

`native(…)` renders a form whose values go to the keychain for the plugin's [native half](/docs/plugins/native) to read. Plugin TypeScript never sees them.

## Preferences

Fields the settings page renders. Values arrive typed in `api.data.preferences.get()` and `usePreferences(api)`.

```ts
preferences: {
  apiKey: field.password({ title: 'API key' }),          // string | null, keychain
  region: field.select({
    title: 'Region',
    options: [{ value: 'us', title: 'US' }, { value: 'uk', title: 'UK' }],
    default: 'us',
  }),                                                     // 'us' | 'uk'
  autoplay: field.checkbox({ title: 'Autoplay', default: true }), // boolean
  uploadSlots: field.number({ title: 'Upload slots', default: 2 }), // number
  username: field.text({ title: 'Username' }),            // string | null
  sharedFolders: field.folders({ title: 'Shared folders' }), // readonly string[], [] until picked
},
```

Passwords go to the keychain; everything else to `preferences.json`, which stays on this device.

`field.folders` renders a list of folders, each with **Remove**, and **Add folder**, which opens the system folder dialog. Its value is absolute paths, and empty until the user adds one: a plugin gets no folder it wasn't handed here.

## Pages

A page mounts at `/p/<plugin>/<page>`. `params` is a zod schema over the URL's search.

```ts manifest.ts
pages: {
  home: { title: 'Podcasts' },
  search: { title: 'Search', params: z.object({ q: z.string().default('') }) },
  show: { title: 'Podcast', params: z.object({ podcastUuid: z.string() }) },
},
```

```tsx index.tsx
definePlugin(manifest, {
  area: { icon: Podcast, pages: ['home', 'search'], search: 'search' }, // lists it in the sidebar
  pages: {
    home: { component: HomePage },
    search: { component: SearchPage, icon: Search }, // optional: its row's icon
    show: { component: ShowPage },
  },
  layout: PodcastsLayout, // optional: wraps every page
})

function ShowPage({ api, params }: PageProps<typeof manifest, 'show'>) {
  // params.podcastUuid: string
}
```

`area` gives the plugin a rail icon, named by the manifest's `name`, and a column of the pages in `area.pages`, in order. The rail icon opens the first, then goes back to wherever in the plugin you left it; `home` is listed as Home. A page needing a param can't be listed: `area.pages: ['show']` doesn't compile. A row's icon is its page's `icon`, else the area's.

`area.search` is the page ⌘K's last row opens on the plugin's pages, as **Search Podcasts for "…"**, with the typed text as `q`. It must take a `q` and need no other param.

| Field | Meaning |
| --- | --- |
| `title` | The page's sidebar label, when `area.pages` lists it. |
| `params` | Parsed from the URL's search. Use plain `z.string()`, `z.number()`, `z.boolean()`, not `z.coerce`. |
| `requires` | A service key. The page shows the not-set-up state until that service is ready. |

Links between pages are typed: `<PageLink page="show" params={{ podcastUuid }}>` (from the plugin's `pluginUi(manifest)`, see [Host components](/docs/plugins/api#host-components)) and `api.app.navigate({ page: 'show', params: { podcastUuid } })` fail to compile on a misspelt page or a missing param.

## Collections

Synced data the plugin owns. The manifest declares each collection; the definition supplies its zod record schema.

```ts manifest.ts
collections: {
  channels: { title: 'YouTube channels', version: 1 },
},
```

```ts collections.ts
import { z } from 'zod'
import { timestampMs, withSchemas } from '@playactor/plugin/data'
import { manifest } from './manifest.ts'

export const schemas = {
  channels: z.object({ id: z.string(), userId: z.string(), title: z.string(), starredAt: timestampMs.nullable() }),
}
export const collections = withSchemas(manifest.collections, schemas)
```

```ts index.ts
definePlugin(manifest, { collections: schemas, activate(api) { /* api.data.collections.channels */ } })
```

Each registers as `<pluginId><Key>` (`youtubeChannels`) and syncs with the rest of the library. Rows carry `userId: api.data.workspaceId()`. Bump `version` only for a breaking shape change; an added optional field needs none.

Because the worker and the collection registry read collections from Node, a plugin's collections module imports zod and `@playactor/plugin/data` only. Add the plugin to `packages/collections/src/pluginCollections.ts` beside YouTube.

## Sources

A web video the plugin hands the player or downloads has a ref, `{ ns, id }`, and its clips, title and download are keyed `<ns>:<id>`. A plugin owns its own id as a namespace; one that lists videos from several sites names them instead, so each site's keys stay the site's:

```ts
defineManifest({ id: 'adult', name: 'Adult', sources: ['xhamster', 'pornhub'], /* … */ })
// Player, api.app.player and api.app.downloads take { ns: 'xhamster', id: 'xhYZtyw' }
```

A ref outside `sources` throws, except a web video's (`api.app.web.source` mints those). No two plugins may own one namespace, and `web` is the host's.
