Using the libraries
Talk to a deck without the app.
The packages under Studio work on their own: talk to a deck, draw on it with React, or build a
whole app for it. They need Bun or Node 20+; node-hid comes with @sdeck/core.
Quick start
import { openStreamDeck } from "@sdeck/elgato";
// Waits until a Stream Deck is plugged in.
const deck = await openStreamDeck();
await deck.setBrightness(60);
await deck.setKeyImage(0, "icon.png"); // PNG, JPEG, WebP, a path, bytes, or a React element
deck.on("keyDown", (key) => console.log("pressed", key));
deck.on("dialTurn", (dial, ticks) => console.log("turned", dial, ticks));deck.model says which one it is, and keyCount, sensorCount and dialCount what it has. To open only
some of them, pass their ids: openStreamDeck({ models: ["plus", "plus-xl"] }).
Staying connected
manageDeck waits for a deck, sets it up, notices when it is unplugged (heartbeat plus error
probing) and sets it up again when it returns.
import { manageDeck } from "@sdeck/core";
import { openStreamDeck } from "@sdeck/elgato";
const handle = manageDeck({
open: (signal) => openStreamDeck({ signal }),
setup: (deck) => deck.setBrightness(80), // runs on every (re)connect
onStatus: (status) => console.log(status), // "waiting" | "connected" | "stopped"
});
process.once("SIGINT", () => handle.stop());