JavaScript SDK

Add the client, identify your users, and you're live.

Last reviewed

JavaScript SDK

The JavaScript SDK gives you a lightweight client to add getuserfeedback.com to any browser app.

Install & setup

1. Install

npm install @getuserfeedback/sdk

2. Create the client

Create one client and reuse it across your app.

TypeScriptapp.ts
import { createClient } from "@getuserfeedback/sdk";const client = createClient({apiKey: "YOUR_API_KEY",});

The only required option is apiKey — find it in Widget settings.

You're live

That's it. The widget is running. Published flows — surveys, forms, and in-app messages — will show up when their delivery and targeting rules match.

3. Identify your users

If your app has logged-in users, identifying them enables targeting, personalization, and behavioral segmentation.

TypeScriptauth.ts
await client.identify("user_123", {email: "user@example.com",plan: "pro",});

If you don't have a stable user ID yet, traits-only mode also works:

await client.identify({email: "user@example.com",});

This step is optional — flows work fine without it. But with user identity, you can target by plan, role, or behavior, and responses are tied to real people. See Personalization for the full picture.

Call reset() on logout so the previous user's identity doesn't carry over.

Track product events

We recommend sending product events server-side through an integration such as Segment. If client-side tracking fits your app better, use track().

You can call track() before or after login. When the same person is later identified, Identity resolution merges their events into a single profile. See Events for SDK examples, event naming, and property guidance.

Dark mode

The widget automatically matches your app's color scheme, and you can override it when needed. See Dark mode for detection behavior and SDK examples.

By default, the widget starts with granted consent. Consent-first apps can start with pending and update consent from their existing cookie banner or consent manager.

Consent settings do not block response collection or flows opened from code. They can prevent automatic targeting when its rules need measurement or storage. See Compliance & consent for scope behavior and SDK examples.

Going further