Skip to content

Desktopr Bridge

This is the official JavaScript/TypeScript SDK for communicating with the native Desktopr bridge.
It allows any web application to access native desktop features exposed by the Desktopr wrapper, using a clean, typed, importable API.

If the app is running in a normal browser environment, the SDK provides a safe detection method isDesktoprAvailable() so you can fallback.


Installation

bash
  npm install desktopr

or

bash
  yarn add desktopr

Usage

ts
  import { Desktopr, isDesktoprAvailable } from "desktopr";

  if (isDesktoprAvailable()) {
    await Desktopr.window.new();
  } else {
    console.log("Running in browser mode — native features unavailable.");
  }

API Shape

The SDK exposes TypeScript definitions for the entire bridge via DesktoprAPI, ensuring autocomplete and type safety.


Detecting Native Environment

The SDK includes a lightweight helper:

ts
  isDesktoprAvailable()

It never throws, even in SSR or when running outside Desktopr.

Useful for apps that must run both:

  • as a normal website
  • and as a desktop app wrapped with Desktopr

When Desktopr Is Not Available

If Desktopr is missing (e.g. browser mode), trying to call native APIs directly will throw.

Make sure to guard features or provide fallbacks:

ts
  if (!isDesktoprAvailable()) return;
  await Desktopr.window.new(...);

Modules

ModuleDescription
appControl application-level behaviors and retrieve app information.
notificationsManage system notifications, including sending and scheduling notifications.
clipboardRead from and write to the system clipboard.
filesAccess and manipulate files on the local filesystem.
windowControl and query application window behaviors (resize, focus, etc.).
eventsListen for and emit custom or system events.
globalShortcutRegister and handle global keyboard shortcuts.
fsProvides a dadicated filesystem for the app.
menuManage and update application native menus.
diagnosticsAccess diagnostic tools and logs for troubleshooting.
networkPerform network requests and monitor connectivity state.
autostartManage application auto-start behavior on system login.
badgeSet the application badge count (macOS only).
workerRun background tasks in worker threads.

Platform Notes

  • The badge functionality, which allows setting an application badge count, is currently supported only on macOS.

WARNING

Cross-Platform Limitations: Some modules and features may behave differently or be unavailable depending on the operating system. Always check for availability and handle fallback logic accordingly.

All rights reserved.