buttplug.js

Getting Started

Install buttplug.js and connect to your first device


Installation

bun add @zendrex/buttplug.js
npm install @zendrex/buttplug.js
pnpm add @zendrex/buttplug.js

Setup

Install the package

Add @zendrex/buttplug.js to your project using the command above.

Start Intiface Central

Download and launch Intiface Central. Click Start Server -- it listens on ws://localhost:12345 by default.

Connect and scan

Create a ButtplugClient, connect to the server, and start scanning for devices.

import { ButtplugClient } from "@zendrex/buttplug.js";

const client = new ButtplugClient("ws://localhost:12345");
await client.connect();
await client.startScanning();

Control a device

Listen for the deviceAdded event and send commands to discovered devices.

client.on("deviceAdded", async ({ device }) => {
  console.log(`Found: ${device.name}`);
  await device.vibrate(50);
});

Full Example

import { ButtplugClient } from "@zendrex/buttplug.js";

const client = new ButtplugClient("ws://localhost:12345");

client.on("deviceAdded", async ({ device }) => {
  console.log(`Found: ${device.name}`);
  if (device.canOutput("Vibrate")) {
    await device.vibrate(50);
  }
});

await client.connect();
await client.startScanning();

The client connects over WebSocket, performs a protocol handshake, and begins scanning for devices. When a device is found, the deviceAdded event fires with a Device instance that exposes typed control methods.

Scanning runs until you call client.stopScanning() or the server emits scanningFinished. Devices persist across scans -- you only receive deviceAdded once per device until it disconnects.

For connection options like auto-reconnect and custom timeouts, see Connecting. For the full device control API, see Devices.

On this page