Skip to Content
sdeck docs

Building an app

Pages, components and hooks for a deck app of your own.

import { BackButton, Clock, defineApp, KeyButton, runApp, useNavigation } from "@sdeck/app";

const app = defineApp({
  pages: {
    home: {
      keys: { 0: <KeyButton onPress={() => {}}>Go</KeyButton> },
      window: <Clock />,
    },
  },
  brightness: 70,
});

const handle = runApp(app, { onStatus: console.log });
process.once("SIGINT", () => handle.stop());

runApp handles detection and reconnecting and redraws on the page the user was on.

Components: KeyButton and SensorButton (for the touch strips, in pages.*.sensors), both with onPress, onLongPress and onDoublePress; BackButton; Clock. pages.*.dials is what the touch strip shows above each dial; a page without any shows its window there. Without gestures, onPress fires on the press itself. With onLongPress or onDoublePress it waits for the release (and the double-press window) so the gestures can be told apart.

Hooks: useNavigation, useKeyPress, useKeyPressed, useKeyRepeat, usePress (a key, a sensor or a dial), useHold (something when pressed, something else when let go), useSensorPress, useSensorPressed, useSensorRepeat, useDialTurn, useDialPress, useDialPressed, useDialRepeat, useSwipe, useNow, useInterval, useDeck, useDimmed, useSlot. runApp opens any Stream Deck; openDeck in its options chooses which.