Build an app / Manifest & commands

Manifest & commands

Tell WorkOS which URL to launch, which files your app can open, and where its commands belong.

Register your app

Link the manifest from the page that users will install. The starter’s manifest works at the root of a domain or under a path such as /tools/word-count/.

index.html

<link rel="manifest" href="./manifest.webmanifest">

manifest.webmanifest

{
  "name": "Word Count",
  "start_url": "./index.html",
  "scope": "./",
  "display": "standalone",
  "icons": [{ "src": "./icon.svg", "sizes": "any", "type": "image/svg+xml" }],
  "file_handlers": [{
    "action": "./index.html",
    "accept": { "text/plain": [".txt"], "text/markdown": [".md"] }
  }],
  "workos": {
    "version": 1,
    "capabilities": ["files.read"]
  }
}

WorkOS resolves start_url, scope, and action URLs relative to the manifest. Keep actions on the same origin and inside the app’s scope. The starter omits id, so the resolved start URL identifies the installation. If the start URL may move, set a stable, origin-relative ID such as /tools/word-count/ before distributing the app.

Open files from the desktop

file_handlers associates a MIME type or filename suffix with an action URL. Declare files.read to appear in Open With…. An eligible installation receives the chosen file as a handle. The starter subscribes as soon as the module loads so a file selected before the window opened still reaches the counter.

app.js

const activation = app.onActivation(({ files = [] }) => {
  if (files[0]) void showCount(files[0]);
});
await activation.ready;

A handle belongs to the current window and document. Release it after use. On navigation or close, request a new handle when the user next opens a file.

Add a window command

For a command that explains how counting works, add this commands array inside the manifest’s workos object.

manifest.webmanifest · workos member

"commands": [{
  "id": "about-count",
  "title": "How words are counted",
  "location": "window"
}]

In the starter’s existing onActivation callback, add command to the destructuring parameter and handle the matching ID. Reinstall from the same profile to review the new declaration, then invoke the command in the window menu.

app.js · inside the activation callback

if (command === 'about-count') {
  status.textContent = 'Words are separated by whitespace.';
}
LocationWhere it runs
windowIn the window whose menu was used.
filesOn one selected regular file, with a read-only handle. Requires files.read. Filter with extensions such as ["md", "txt"].
desktopFrom the desktop, launching the app if needed.
launcherFrom the launcher. Standard manifest shortcuts can also point to in-scope URLs.

Use a unique ID and a title of 1–80 characters each. WorkOS reads up to 24 custom commands and reserves the shortcut. ID prefix. Download the workos member JSON schema.