Skip to content

tyndWindow

import { tyndWindow } from "@tynd/core/client";

Every call auto-targets the window it runs in. Each WebView has an injected __TYND_WINDOW_LABEL__ used for routing. The primary window’s label is "main".

const isMax = await tyndWindow.isMaximized();
const isMin = await tyndWindow.isMinimized();
const isFull = await tyndWindow.isFullscreen();
const isVis = await tyndWindow.isVisible();
const isRes = await tyndWindow.isResizable();
const isCls = await tyndWindow.isClosable();
const isMinB = await tyndWindow.isMinimizable();
const isMaxB = await tyndWindow.isMaximizable();
const onTop = await tyndWindow.isAlwaysOnTop();
const kiosk = await tyndWindow.isKiosk();
const isFoc = await tyndWindow.isFocused();
const isDec = await tyndWindow.isDecorated();
const label = tyndWindow.label(); // sync — "main" / "settings" / …
await tyndWindow.setTitle("My App — Unsaved");

Logical pixels — divide by scaleFactor() for device pixels.

await tyndWindow.setSize(1400, 900);
const innerSize = await tyndWindow.getSize(); // { width, height } — client area
const outerSize = await tyndWindow.getOuterSize(); // includes title bar + borders
await tyndWindow.setPosition(100, 100);
const { x, y } = await tyndWindow.getPosition(); // outer frame
const inner = await tyndWindow.getInnerPosition(); // client area, below the title bar
await tyndWindow.setMinSize(400, 300);
await tyndWindow.setMaxSize(1920, 1080);
await tyndWindow.setAspectRatio(16 / 9); // keep 16:9 while resizing; null clears
const dpi = await tyndWindow.scaleFactor(); // 1.0 / 1.5 / 2.0
await tyndWindow.maximize();
await tyndWindow.unmaximize();
await tyndWindow.toggleMaximize();
await tyndWindow.minimize();
await tyndWindow.unminimize();
await tyndWindow.setFullscreen(true);
await tyndWindow.setSimpleFullscreen(true); // macOS: no new Space, no animation
await tyndWindow.setKiosk(true); // borderless fullscreen pinned above everything

setKiosk(false) leaves fullscreen and restores the previous always-on-top state. Start an app in kiosk mode with window: { kiosk: true }.

await tyndWindow.show();
await tyndWindow.hide();
await tyndWindow.setFocus(); // bring to front + keyboard focus
await tyndWindow.requestAttention(); // flash taskbar / bounce Dock once
await tyndWindow.requestAttention("critical"); // keep going until the window is focused
await tyndWindow.cancelAttention();

Show the window when ready (splash screen)

Section titled “Show the window when ready (splash screen)”

The primary window is shown once its first page has rendered. To decide yourself, start it hidden with window: { visible: false } in app.start() and call show() from the frontend when the UI is ready:

// backend
app.start({ window: { title: "My App", visible: false } });
// frontend
await loadSettings();
await tyndWindow.show();

For a separate splash window, open it with the multiwindow plugin, then close it after show().

Resizable / closable / maximizable / minimizable

Section titled “Resizable / closable / maximizable / minimizable”
await tyndWindow.setResizable(false);
await tyndWindow.setClosable(false);
await tyndWindow.setMaximizable(false);
await tyndWindow.setMinimizable(false);
await tyndWindow.setMovable(false); // Windows / macOS; rejects on Linux
await tyndWindow.setDecorations(false); // no title bar (build your own via CSS)
await tyndWindow.setAlwaysOnTop(true);
await tyndWindow.setAlwaysOnTop(true, { level: "screen-saver" }); // above fullscreen apps (macOS)
await tyndWindow.setAlwaysOnBottom(true); // desktop widgets
await tyndWindow.setOpacity(0.9); // 0..1, includes the page
await tyndWindow.center();

level is "floating" (default), "status" or "screen-saver". macOS maps each to its window level; Windows and Linux have a single topmost band, so every level behaves the same there.

Frameless windows: drag regions and resize edges

Section titled “Frameless windows: drag regions and resize edges”

With decorations: false, mark the elements of your custom title bar with HTML attributes; the injected bridge script handles them, no JavaScript needed:

<header data-tynd-drag>
<span>My App</span>
<div data-tynd-no-drag><input placeholder="Search" /></div>
<button id="minimize">–</button> <!-- calls tyndWindow.minimize() -->
</header>
<div data-tynd-resize="se" class="grip"></div>
Attribute Effect
data-tynd-drag Mouse-down drags the window from this element and its children; double-click toggles maximize
data-tynd-no-drag Opts an element and its children out of the enclosing drag region
data-tynd-resize="n|ne|e|se|s|sw|w|nw" Mouse-down starts a native resize from that edge or corner

Controls inside a drag region (button, input, select, textarea, a, [contenteditable], [role=button]) stay clickable. A frameless, resizable, non-maximized window also resizes from a 5 px strip along the page border, with the matching resize cursor, on Windows and Linux; macOS resizes borderless windows natively.

On macOS, keep the traffic lights over your own title bar with window: { titleBarStyle: "overlay" } (transparent title bar, hidden title, page drawn underneath; "transparent" keeps the title). Move the buttons with setTrafficLightInset(x, y) and leave room for them in your layout. titleBarStyle is ignored on Windows and Linux: WebView2 and WebKitGTK cannot draw native caption buttons over the page, so use decorations: false with your own buttons (minimize(), toggleMaximize(), app.exit() or multiwindow.closeSelf()) inside a data-tynd-drag bar.

await tyndWindow.reload();
await tyndWindow.setZoom(1.25);
const zoom = await tyndWindow.getZoom();
await tyndWindow.openDevTools(); // debug builds only
await tyndWindow.closeDevTools();
// Runtime navigation + print (native host)
await tyndWindow.navigate("/reports");
await tyndWindow.loadHtml("<h1>Hello</h1>");
const url = await tyndWindow.getUrl();
await tyndWindow.print(); // opens the system print dialog
// Cmd+F-style in-page search (synchronous; uses the WebView's window.find).
const hit = tyndWindow.findInPage("invoice", { caseSensitive: false });
tyndWindow.stopFindInPage();
await tyndWindow.setTitle("Pro · 12 files open");
const title = await tyndWindow.getTitle();
await tyndWindow.setTheme("dark"); // "light" | "dark" | "system"
await tyndWindow.setBackgroundColor({ r: 20, g: 20, b: 28 });
await tyndWindow.setShadow(false); // macOS; Windows frameless windows
await tyndWindow.setWindowIcon("/abs/new-icon.png");
await tyndWindow.setProgressBar("normal", 42); // taskbar / dock / Unity
await tyndWindow.setBadge({ count: 3 }); // macOS dock / Windows taskbar overlay / Linux launcher
await tyndWindow.setSkipTaskbar(true); // Windows / Linux
await tyndWindow.setContentProtection(true); // blocks screenshots + capture
await tyndWindow.setVisibleOnAllWorkspaces(true); // macOS Spaces
await tyndWindow.setEffects({ effects: ["mica", "sidebar"] }); // first material the OS supports; [] clears
await tyndWindow.setTitlebarTransparent(true); // macOS
await tyndWindow.setFullsizeContentView(true); // macOS — HTML extends under titlebar
await tyndWindow.setTrafficLightInset(12, 18); // macOS — reposition window controls

Calls that cannot have any effect on the current OS reject with "<method>: only supported on <OS>" (or not supported on <OS>) instead of resolving silently: setEnabled off Windows, setEffects when no listed effect runs on the OS (always on Linux), setAspectRatio and setMovable on Linux. setBadge shows label on macOS (a bare count is shown as text), draws label (at most 3 characters) or count (99+ above 99) as a taskbar overlay icon on Windows, and shows count on Linux, where a label-only call rejects. {} clears the badge.

Call Windows macOS Linux
setAlwaysOnTop(…, { level }) topmost (level ignored) window level keep-above (level ignored)
setAlwaysOnBottom yes yes yes
setKiosk yes yes yes
setSimpleFullscreen borderless fullscreen non-native fullscreen borderless fullscreen
setOpacity yes yes compositing WM
setAspectRatio yes yes rejects
setMovable yes yes rejects
setShadow frameless windows yes no-op
requestAttention("critical") flashes until focused bounces until focused urgent hint
setBadge overlay icon (label up to 3 chars or count) Dock label launcher count
setEffects mica, tabbed (11), acrylic, blur NSVisualEffectView materials rejects
titleBarStyle option ignored yes ignored
Automatic resize border yes native yes

setEffects applies a native material behind the page. List effects in order of preference: the first one the running OS supports wins, so one call covers Windows and macOS. The material shows only where the window is transparent (transparent: true) and the page background is transparent.

await tyndWindow.setEffects({ effects: ["mica", "underWindowBackground"] });
await tyndWindow.setEffects({ effects: ["acrylic"], color: "#20202080" }); // tinted acrylic
await tyndWindow.setEffects({ effects: [] }); // clear
Option Type Applies to Notes
effects WindowEffect[] all [] clears; rejects when none runs on the OS
state "followsWindowActiveState" | "active" | "inactive" macOS default follows the window’s active state
radius number macOS corner radius in points, 0-1000
color "#rrggbb" / "#rrggbbaa" Windows acrylic, blur tint
Effect OS
mica, tabbed Windows 11
acrylic Windows 10 1809+ / 11
blur Windows 10 / 11 (can lag while resizing on Windows 11 22621)
titlebar, selection, menu, popover, sidebar, headerView, sheet, windowBackground, hudWindow, fullScreenUI, tooltip, contentBackground, underWindowBackground, underPageBackground macOS
await tyndWindow.setFocusable(false);
await tyndWindow.setEnabled(false); // Windows only (blocks mouse + keyboard input); rejects elsewhere
await tyndWindow.setCursorIcon("grab"); // 35 icons: grab, grabbing, zoomIn, text, wait, crosshair, ...
await tyndWindow.setCursorPosition(320, 240);
await tyndWindow.setCursorVisible(false);
await tyndWindow.setCursorGrab(true); // confine the cursor to the window
await tyndWindow.setIgnoreCursorEvents(true); // click-through — mouse passes to windows behind
// Drag / resize from script (data-tynd-drag / data-tynd-resize need none).
dragHandle.addEventListener("mousedown", () => void tyndWindow.startDragging());
resizeCorner.addEventListener("mousedown", () =>
void tyndWindow.startResizeDragging("southEast"),
);
tyndWindow.onDragEnter(({ paths }) => highlightDropZone(paths.length));
tyndWindow.onDragOver(({ x, y }) => trackPosition(x, y));
tyndWindow.onDragLeave(() => clearDropZone());
tyndWindow.onDrop(({ paths }) => {
for (const p of paths) void openFile(p); // p is a real OS path, not a File
});

Start a native file drag from a mousedown or dragstart handler while the button is held. The files land in Explorer, Finder, a mail client or any other drop target.

thumbnail.addEventListener("dragstart", (event) => {
event.preventDefault();
void tyndWindow.startDrag({ files: [exportPath], icon: "/abs/path/preview.png" });
});

files holds 1 to 1024 absolute paths; icon is an image path or PNG bytes (Uint8Array), and defaults to the system file icon. Every path goes through the fs policy and capability roots, like an fs read.

Or declare it in HTML: data-tynd-drag-file on a draggable element (an image, a link or draggable="true") starts the drag with that path. Separate several paths with newlines.

<img src="preview.png" data-tynd-drag-file="/Users/me/Exports/report.pdf" />
tyndWindow.onNavigation(({ url, allowed }) => {
// allowed === false when the active `security` policy blocks the URL
if (!allowed) log.warn("navigation blocked", { url });
});
tyndWindow.onPageLoad(({ phase, url }) => {
if (phase === "finished") hideSplash();
});
await tyndWindow.positionAt("topRight", 20);
// "topLeft" | "topRight" | "topCenter" | "leftCenter" | "rightCenter"
// | "bottomLeft" | "bottomRight" | "bottomCenter" | "center"
// | "trayLeft" | "trayRight" | "trayCenter" | "trayBottomCenter"

tyndWindow is the handle of the window it runs in. The multiwindow plugin opens secondary windows and returns handles with the same methods for any label:

Terminal window
tynd add multiwindow
import { multiwindow } from "@tynd/plugin-multiwindow/client";
const settings = await multiwindow.create({ label: "settings", url: "/settings", title: "Settings" });
await settings.setSize(640, 480);
await (await multiwindow.getWindow("main"))?.setTitle("Editing");
await settings.close();

On a secondary window, setMenu(items) sets its own menu bar (Windows and Linux) and setMenu(null) removes it; on the primary window it replaces the application bar. close() closes a secondary window.

From the Bun backend, getWindow(label = "main") from @tynd/core returns the same handle. Backend handles subscribe to the same on* events, except onDragOver; see Backend API.

import { getWindow } from "@tynd/core";
await getWindow().setAlwaysOnTop(true);

See the Multi-Window guide.

All on* return unsubscribe(). Events are delivered to every app-local webview (never to remote content) and auto-filtered to the calling window’s label by the client helper — handlers only fire for their own window.

const offResize = tyndWindow.onResized(({ width, height }) => { /* … */ });
const offMove = tyndWindow.onMoved(({ x, y }) => { /* … */ });
const offFocus = tyndWindow.onFocused(() => { /* regained focus */ });
const offBlur = tyndWindow.onBlurred(() => { /* lost focus */ });
const offTheme = tyndWindow.onThemeChanged(({ theme }) => { /* "light" | "dark" */ });
const offDpi = tyndWindow.onDpiChanged(({ scale }) => { /* 1.5 on 150% */ });
// State transitions — fire only on flip, not initial state.
const offMin = tyndWindow.onMinimized(() => {});
const offUnmin = tyndWindow.onUnminimized(() => {});
const offMax = tyndWindow.onMaximized(() => {});
const offUnmax = tyndWindow.onUnmaximized(() => {});
const offFull = tyndWindow.onFullscreen(() => {});
const offUnfull = tyndWindow.onUnfullscreen(() => {});
// Broadcast — receive events from every window (not filtered).
const offClosed = tyndWindow.onClosed(({ label }) => console.log(label, "closed"));

preventDefault() must be called synchronously in the handler to cancel the close. The close proceeds after 500 ms if nothing cancels it.

interface CloseRequestedEvent {
preventDefault(): void;
}
tyndWindow.onCloseRequested((e) => {
if (hasUnsavedChanges()) {
e.preventDefault(); // must be synchronous
void showSavePromptThenMaybeClose();
}
});

For an async confirm flow that exceeds 500 ms (uses the dialog plugin, tynd add dialog):

import { app, tyndWindow } from "@tynd/core/client";
import { dialog } from "@tynd/plugin-dialog/client";
tyndWindow.onCloseRequested(async (e) => {
if (!dirty) return;
e.preventDefault();
await tyndWindow.cancelClose(); // explicit halt for async cases
const discard = await dialog.confirm("Unsaved changes. Close?");
if (discard) await app.exit(); // in a secondary window: multiwindow.closeSelf()
});

Cancel a pending close. Has effect during the 500 ms window after close-requested — after that, the app has already committed to exiting.

await tyndWindow.cancelClose();

Every HTML response served through tynd:// carries a baseline Content-Security-Policy. Override per-page via <meta http-equiv="Content-Security-Policy">.