Skip to content
npm · typescript · workers

Browser runtime for workers —Droid

The browser-side runtime the KBVE sites boot: a pool of canvas, IndexedDB, WebSocket and Supabase workers behind comlink, a Supabase gateway that picks a shared-worker, web-worker or direct strategy per browser, and the shared UI state the pages read.

One gateway, three strategies

Capability detection picks SharedWorker, a dedicated web worker, or a direct main-thread client, so Supabase calls behave the same on desktop, Android and Safari.

  • Prebuilt workers — canvas, IndexedDB, WebSocket, Supabase shared/DB.
  • Deps — comlink, dexie, zod, nanostores, flatbuffers.
TypeScriptLanguage
npmRegistry
comlinkMessaging
MITLicense

What it gives you

Features

Worker boot

droid() starts the canvas, DB and WebSocket workers from workerURLs or existing worker refs, with an optional init timeout, plus downscale/upscale to free the main thread before heavy WASM work.

Prebuilt workers

Canvas (with a canvas UI renderer), IndexedDB via Dexie, WebSocket, and Supabase shared / DB workers ship as Vite worker URLs.

Supabase gateway

SupabaseGateway, WorkerPool and a lazy pool over SharedWorker, web worker and direct strategies, chosen by capability detection.

Shared UI state

nanostores atoms for auth, profile sync, toasts, tooltips, theme, overlays and bento panels, with persistent storage where it matters.

Service worker recovery

swRecovery unregisters service workers whose script is not on an allow-list and can clear caches and reload, to dig a site out of a stale worker.

Agents client

createAgents, the client behind the Discord bot, guild and GitHub token, webhook and backfill settings, with its form-draft helpers.

Get started

Usage

install
npm install @kbve/droid

Questions

Frequently asked

What is the Droid package?

Droid is the browser-side runtime behind the KBVE Astro sites. It boots a pool of workers (canvas, IndexedDB, WebSocket and Supabase), talks to them over comlink, wraps the Supabase client in a gateway, and holds the shared nanostores state — auth, profile, toasts, tooltips, bento panels — that the UI reads.

Which workers does Droid ship?

A canvas worker with a canvas UI renderer, a Dexie-backed IndexedDB worker, a WebSocket worker, and a Supabase shared worker and DB worker. Each is exported as a Vite worker URL in workerURLs, and droid() boots them with an optional initialisation timeout.

What happens on browsers without SharedWorker?

The Supabase gateway detects capabilities and selects a strategy — SharedWorker where it exists, a dedicated web worker otherwise, or a direct client on the main thread — so the same calls work on Android and Safari.

Is Droid an optional dependency of the Astro package?

No. packages/astro imports it throughout; it is that package's hard dependency, whatever the optional Supabase peerDependency suggests.

Discuss on the forum

Questions, fixes and notes on this page live in the KBVE forum.