Alpha

BridgeClient

Low-level REST client for direct Bridge API access.

Prefer Hooks

For most use cases, we recommend using the React hooks instead of BridgeClient. The hooks provide automatic caching, real-time updates via WebSocket, and proper React integration.

Use BridgeClient only when you need:

  • Direct API access outside of React components
  • One-off requests without caching
  • Custom integration with non-React frameworks

Installation

BridgeClient is included in the SDK:

import { BridgeClient, createBridgeClient } from "@deskctl/sdk";

Usage

import { createBridgeClient } from "@deskctl/sdk";

const client = createBridgeClient({
  host: "192.168.1.100",
  port: 9990,
  secure: false,
  apiKey: "your-api-key", // optional
});

// Health check
const isOnline = await client.ping();

// Get system info
const systemInfo = await client.getSystemInfo();
console.log(`Connected to ${systemInfo.hostname}`);

API Reference

Constructor

const client = new BridgeClient(config);
// or
const client = createBridgeClient(config);

Config options:

OptionTypeDefaultDescription
hoststringrequiredBridge IP or hostname
portnumber9990Bridge port
securebooleanfalseUse HTTPS/WSS
apiKeystring-API key for authentication

Properties

client.baseUrl; // HTTP base URL (e.g., "http://192.168.1.100:9990")
client.wsUrl; // WebSocket URL (e.g., "ws://192.168.1.100:9990/api/ws")

Methods

ping(): Promise<boolean>

Simple health check. Returns true if bridge is reachable.

if (await client.ping()) {
  console.log("Bridge is online");
}

getStatus(): Promise<StatusResponse>

Get detailed status from /api/status.

const status = await client.getStatus();
console.log(status.status); // "ok"

getSystemInfo(): Promise<SystemInfo>

Get static system information (CPU specs, GPU, memory, etc.).

const info = await client.getSystemInfo();
console.log(info.hostname); // "GAMING-PC"
console.log(info.cpu.brand); // "AMD Ryzen 9 5900X"
console.log(info.gpu?.brand); // "NVIDIA GeForce RTX 3080"
console.log(info.memory.total); // 34359738368 (bytes)

Power Control

await client.shutdown(); // Shut down system
await client.restart(); // Restart system
await client.sleep(); // Put system to sleep
await client.hibernate(); // Hibernate system

Process Control

// Kill process by PID
await client.killProcess(1234);

// Kill all processes by name
await client.killProcessByName("notepad.exe");

// Launch application
await client.launchProcess("notepad.exe");
await client.launchProcess("code", ["--new-window", "/path/to/project"]);

Error Handling

All methods throw on failure:

try {
  await client.shutdown();
} catch (error) {
  console.error("Failed to shutdown:", error.message);
}

Example: Connection Test Script

import { createBridgeClient } from "@deskctl/sdk";

async function testConnection(host: string) {
  const client = createBridgeClient({ host, port: 9990 });

  console.log(`Testing connection to ${host}...`);

  const online = await client.ping();
  if (!online) {
    console.log("Bridge is offline");
    return;
  }

  console.log("Bridge is online!");

  const info = await client.getSystemInfo();
  console.log(`Hostname: ${info.hostname}`);
  console.log(`OS: ${info.os.name} ${info.os.version}`);
  console.log(`CPU: ${info.cpu.brand}`);
  if (info.gpu) {
    console.log(`GPU: ${info.gpu.brand}`);
  }
}

testConnection("192.168.1.100");

On this page