JavaScript SDK

Install the widget in any browser app with createClient() and open flows imperatively.

Last reviewed

JavaScript SDK

Use the JavaScript SDK when your app is not React-specific or when you want a small, typed browser client you can control directly.

Install

bun add @getuserfeedback/sdk

If you use another package manager, install the same package there.

Create one client

import { createClient } from "@getuserfeedback/sdk";

const client = createClient({
  apiKey: "YOUR_API_KEY",
});

Reuse the same client across the app. Do not create a new client every time you open a flow.

Open a flow

await client.flow("YOUR_FLOW_ID").open();

Use the same flow handle for prefetch(), prerender(), open(), and close() when you want to keep one flow lifecycle together.

Add later, not first

  • identify() when flows or analytics need user context
  • configure({ auth }) when App Security requires JWTs
  • configure({ colorScheme }) when your app owns light and dark mode
  • disableAutoLoad: true when widget loading should wait for consent