@retainrabbit/js
v0.1.0
Published
Keyless browser SDK to drop RetainRabbit cancellation save-flows into any site.
Readme
@retainrabbit/js
Keyless browser flow controller for RetainRabbit. Opens the hosted cancel-deflection flow in a popup or iframe overlay, speaks the postMessage wire protocol, and guards your cancel button with fail-open behavior. Accepts no API key — the customer is authenticated by workspaceId + flowId (+ optional HMAC-signed email/verify).
Install
pnpm add @retainrabbit/jsUsage
import { createRetainRabbit } from "@retainrabbit/js";
const rr = createRetainRabbit({
origin: "https://app.example.com",
workspaceId: "ws_123",
defaultFlowId: "flow_cancel",
mode: "overlay", // or "popup" (default)
});
// Guard a cancel button: clicks open the flow; if the customer still cancels,
// the original action (handler / <a> / form submit) is re-run automatically.
const detach = rr.guard("#cancel", { email: "[email protected]" });
// Or open imperatively and branch on the outcome:
const outcome = await rr.open(); // "saved" | "canceled" | "dismissed"
// Set defaults applied to later open()/guard() calls:
rr.identify({ email: "[email protected]", verify: "<hmac>" });
// later: detach();If the popup is blocked or the framed flow never mounts within ~8s, the flow fails open and resolves "canceled" so the customer is never trapped.
