app
import { app } from "@tynd/core/client";App identity and lifecycle. Callable from both frontend and backend.
app.setInfo({ name, bundleId })
Section titled “app.setInfo({ name, bundleId })”Sets the app’s name and bundle identifier:
import pkg from "../package.json";await app.setInfo({ name: pkg.name, bundleId: "com.acme.myapp", // reverse-DNS identifier});The client AppInfo type has no version, and the host refuses an app.setInfo call from a renderer that carries one ('version' can only be set by the backend). The version is the updater’s downgrade floor, so only the backend sets it: Tynd’s Bun runtime sends the package.json version to the host at startup, and app.getVersion() returns it.
Used by other APIs (notifications, tray tooltip, OS integration) to identify the app consistently.
app.getName(): Promise<string>
Section titled “app.getName(): Promise<string>”Returns the registered name. Falls back to the binary file stem if setInfo wasn’t called.
const name = await app.getName();app.getVersion(): Promise<string>
Section titled “app.getVersion(): Promise<string>”Returns the registered version. Falls back to "0.0.0".
const version = await app.getVersion();app.getFrameworkVersion(): Promise<string>
Section titled “app.getFrameworkVersion(): Promise<string>”Version of the Tynd host binary, baked in at compile time via CARGO_PKG_VERSION. Surface it in About dialogs + crash reports without rolling your own constant.
const tynd = await app.getFrameworkVersion();app.getBundleIdentifier(): Promise<string | null>
Section titled “app.getBundleIdentifier(): Promise<string | null>”Returns the reverse-DNS identifier set via setInfo({ bundleId }), or null if none was set.
const id = await app.getBundleIdentifier();app.relaunch(): Promise<void>
Section titled “app.relaunch(): Promise<void>”Spawns a fresh copy of the current binary with the same command-line arguments and exits the current process. The single-instance lock is released before the copy starts, so it becomes the primary instance. If the copy cannot be started, the call rejects and the current process keeps running (and keeps the lock).
await app.relaunch();Useful after applying an update, toggling a runtime flag, or loading a new backend.
app.exit(code?: number): Promise<void>
Section titled “app.exit(code?: number): Promise<void>”Exits the app gracefully. The app.onClose hook runs (with its usual 2-second watchdog) before the process terminates.
await app.exit(0);Pass a non-zero code to signal an error to the invoking shell / installer. Default is 0.
app.onOpenFile(handler): { dispose() }
Section titled “app.onOpenFile(handler): { dispose() }”Fires with the absolute path of each document the OS asks the app to open.
const sub = app.onOpenFile((path) => openDocument(path));// later: sub.dispose();| Platform | Source |
|---|---|
| macOS | File-association double-click or “Open with” (file URLs from the app delegate) |
| Windows / Linux | Existing file paths on the command line at launch, and from a second instance forwarded through singleInstance (relative paths resolve against that instance’s working directory) |
Paths that arrive before the first onOpenFile call (typically the file that launched the app) are buffered, up to 256 with the oldest dropped, and delivered to the first handler. Non-file URLs are not reported here; use singleInstance.onOpenUrl. Declare which extensions the app handles with bundle.fileAssociations (see the Deep Linking guide).
app.onReopen(handler): { dispose() }
Section titled “app.onReopen(handler): { dispose() }”macOS only. Fires with { hasVisibleWindows } when the user re-activates the running app (dock icon click). The host does not re-show windows by itself; show or create one when hasVisibleWindows is false. Never fires on Windows or Linux.
app.onReopen(({ hasVisibleWindows }) => { if (!hasVisibleWindows) void tyndWindow.show();});app.addRecentDocument(path): Promise<void>
Section titled “app.addRecentDocument(path): Promise<void>”Adds a file to the OS recent-documents list. The path must pass the fs policy and name an existing file.
await fs.writeText(path, contents);await app.addRecentDocument(path);app.clearRecentDocuments(): Promise<void>
Section titled “app.clearRecentDocuments(): Promise<void>”Clears the app’s recent-documents list.
| Windows | macOS | Linux | |
|---|---|---|---|
addRecentDocument |
Jump list “Recent” category (shown once the app is registered for the file type through bundle.fileAssociations) and Explorer recent items |
“Open Recent” list (NSDocumentController) |
rejects: not supported |
clearRecentDocuments |
Removes the app’s jump-list destinations; Explorer recent items of other apps stay | Clears “Open Recent” | rejects: not supported |
app.setJumpList(list): Promise<void> (Windows)
Section titled “app.setJumpList(list): Promise<void> (Windows)”Replaces the jump list shown when the user right-clicks the taskbar button. Each link relaunches the app executable with its args. With singleInstance the arguments reach the running instance through onSecondLaunch; without it a new process starts with them.
import { app } from "@tynd/core/client";import { singleInstance } from "@tynd/plugin-single-instance/client";
await app.setJumpList({ tasks: [ { title: "New window", args: ["--new-window"], description: "Open another window" }, { title: "Compose", args: ["--compose"], icon: "C:/Program Files/Acme/compose.ico" }, ], categories: [ { name: "Pinned projects", items: [{ title: "Acme site", args: ["--open", "D:/work/acme site"] }] }, ],});
singleInstance.onSecondLaunch(({ argv }) => { if (argv.includes("--new-window")) void openWindow();});| Field | Type | Notes |
|---|---|---|
tasks |
JumpListItem[] |
“Tasks” section, at most 32 links. |
categories |
{ name, items }[] |
Custom sections, at most 16, each with 1 to 32 links and a unique name (1 to 260 characters). |
showRecent |
boolean |
Keep the “Recent” section fed by addRecentDocument. Default true. |
item.title |
string |
1 to 260 characters. |
item.args |
string[] |
At most 32 arguments, quoted for you; the joined command line is limited to 1024 characters. |
item.description |
string |
Tooltip, up to 1024 characters. |
item.icon / item.iconIndex |
string / number |
.ico, .exe or .dll holding the icon (must pass the fs policy) and its index. Defaults to the app icon. |
Links the user removed from a custom section are skipped: Windows refuses to add them back. app.clearJumpList() removes the custom list.
| Windows | macOS | Linux | |
|---|---|---|---|
setJumpList / clearJumpList |
ICustomDestinationList |
rejects: not supported (use app.dock.setMenu) |
rejects: not supported |
Dock (macOS)
Section titled “Dock (macOS)”await app.dock.hide(); // menu-bar app: no Dock icon, no menu barawait app.dock.show();const id = await app.dock.bounce("critical"); // bounces until the app is activatedawait app.dock.cancelBounce(id);await app.dock.setIcon("/abs/badge-icon.png"); // null restores the bundle iconawait app.dock.setMenu([ { id: "new-window", label: "New Window" }, { type: "separator" }, { id: "pause", label: "Pause sync", type: "checkbox", checked: false },]);await app.setActivationPolicy("accessory"); // "regular" | "accessory" | "prohibited"| Call | Notes |
|---|---|
dock.show() / dock.hide() |
Activation policy "regular" / "accessory". Hiding also hides the menu bar; windows stay usable. |
setActivationPolicy(policy) |
"prohibited" also keeps the app from being activated. |
dock.bounce(type?) |
"informational" (default, once) or "critical". Resolves to a request id, 0 when the app is already active. |
dock.cancelBounce(id) |
Unknown ids are ignored. |
dock.setIcon(path | null) |
The path must pass the fs policy. Lasts until the app quits. |
dock.setMenu(items) |
Same item shape as the application menu; clicks emit menu:action. [] removes it. Needs the menu API in the build. |
Every Dock call rejects with “not supported on windows / linux” off macOS. Use tyndWindow.requestAttention, tyndWindow.setBadge (taskbar overlay on Windows) and tyndWindow.setWindowIcon there.
app.exit(0)is preferable toprocess.exit(0)— the former runs lifecycle hooks, the latter doesn’t.relaunchstarts the current executable directly, then exits about 100 ms later after running the cleanup hooks.
Related
Section titled “Related”- Single Instance guide — argv forwarding.
- Updater —
install({ relaunch: true })usesapp.relaunchinternally.