oss.sarwagya.wtf

Installation

Add the package and check what the runtime supports.

Install
pnpm add @0xsarwagya/handoff# or: npm install @0xsarwagya/handoff

One entry point, zero dependencies. The protocol primitives (encodeHandoff, decodeHandoff) run anywhere with TextEncoder and JSON — every browser, Node 18+, Deno, Bun, workers. The browser conveniences (createHandoff, fragment reading) additionally use location and history where available.

Runtime requirements

Compression uses the Compression Streams API — baseline in Chromium, Firefox, and WebKit since May 2023. It is optional by design:

import { capabilities } from "@0xsarwagya/handoff";
 
capabilities();
// { compression: true, supported: true }

Without Compression Streams, encoding degrades to uncompressed artifacts (they still work, just bigger); receiving a compressed artifact in such a runtime fails with a typed UNSUPPORTED error.