Typed client
The same engine as the script tag, called from your code. Open a survey on your own trigger, say who is answering, and let the compiler check every call.
The package is being prepared for npm. Until it is published, the script tag gives you the same surveys and the same window.Respondo API.
Start a survey
app.ts
import { createRespondo } from "respondo";
const respondo = createRespondo({
key: "rsp_pk_…",
surveyId: "…",
});
// Fetches the survey, applies targeting, sampling, the
// delay and the once-only rule, then opens the card.
respondo.start();Options
| Name | Type | What it does |
|---|---|---|
| key | string | Your publishable key, rsp_pk_…. Safe to ship in your bundle. |
| surveyId | string | Which survey to run. |
| person | Person | Who is answering, if you know at start-up. Can also be set later with identify. |
| onSession | (session) => void | Render your own UI instead of the built-in card. See Your own UI. |
| force | boolean | Skip the eligibility checks and open immediately — for a preview, or a button the user pressed on purpose. |
| apiUrl | string | Where Respondo lives. Defaults to https://app.myrespondo.com. |
Methods
| Name | Type | What it does |
|---|---|---|
| start(options?) | Promise<Session | null> | Fetch, check eligibility and open if it applies. Pass { force: true } to skip the checks. Resolves to null when the survey does not apply. |
| show() | Promise<Session | null> | Open now, ignoring the delay, targeting and the once-only rule. |
| identify(person) | void | Say who is answering. Read when the response is sent, not when the card renders. |
| reset() | void | Forget that this browser answered, so it can be shown again. |
| badge(options?) | HTMLAnchorElement | The “Powered by Respondo” lockup. color sets its colour; text is "powered" or "survey". |
Say who is answering
Responses are anonymous unless you say otherwise: each browser gets a random id, so a partial answer can be told from a new one. Pass a Person to attach more. Every field is optional; put your own user id in traits.
after sign-in
respondo.identify({
email: user.email,
name: user.name,
traits: { plan: "team", userId: user.id },
});Open on your own trigger
Set the survey’s trigger to manual in Respondo, then call show() when the moment is right — after a checkout, or behind a “Give feedback” button.
feedback-button.ts
button.addEventListener("click", () => {
respondo.show();
});