# A feedback widget that stays inside your app

Canonical: https://feeblo.com/features/widget Markdown mirror of: https://feeblo.com/features/widget

Mount the widget, open your board in an overlay, and attach the person who is already signed in. The SDK ships for vanilla JavaScript and React, and the widget is open source.

- Install: `npm install @feeblo/sdk` or `npm install @feeblo/sdk @feeblo/sdk-react`
- Quickstart: https://docs.feeblo.com/developers/quickstart
- Source: https://github.com/G3root/feeblo

## One widget, three entry points

The mode decides what the user sees first. You can change it per surface: a submit button in your settings page, an updates panel in your app shell, or a hub that carries both.

- **Feedback.** The submit form. This is the default mode, so one init call gives you a title, a body, a board, and a submit button inside an overlay.
- **Updates.** A card panel of published changelog entries. Use it when the widget should announce what shipped instead of asking for a new idea.
- **Hub.** Both modules behind one launcher. The `modules` array decides which opens first, and `openModule` switches between them without closing the overlay.

Hub mode defaults to `["feedback", "updates"]` when you omit `modules`. Board selection only applies while the feedback module is the active one.

The overlay matters because feedback usually arrives at the moment of frustration. A user should not lose the screen they were on to describe what went wrong. The widget opens over your app, keeps the board in an iframe, and closes back to the same place. The form and the board are the same board your public page serves, so a post submitted here is not a separate inbox.

### Placement and trigger

Set `placement` to `bottom-left` or `bottom-right` and the SDK draws a launcher 20px from that corner. Omit it and no launcher mounts. You open the widget from your own button instead.

### Theme and language

The `theme` option is forwarded to the widget iframe. `locale` takes a BCP 47 tag, and the widget uses its language subtag, with English as the default.

### A board per init

`defaultBoard` picks the board the feedback module opens on. It applies while feedback is the active module, so a hub can route different buttons to different boards.

## Install

Install `@feeblo/sdk` for vanilla JavaScript, or add `@feeblo/sdk-react` for the provider and hooks. Both packages ship ESM and UMD builds with no runtime dependencies. The React package depends on the core SDK and re-exports its API.

The organization ID comes from Settings, then Widget, then Installation. Init throws an embed error with code `INVALID_ORG` when it is missing or empty, so a bad ID fails at startup instead of at submit time.

```bash
npm install @feeblo/sdk
```

```ts
import { Feeblo } from "@feeblo/sdk";

const widget = Feeblo.init("org_123", {
  mode: "hub",
  placement: "bottom-right",
});

widget.open();
```

Give any element the `data-feeblo-feedback` attribute and the SDK opens the widget when a user clicks it:

```html
<button data-feeblo-feedback>Give feedback</button>
```

That works at the DOM level, so it is the same in React or any other framework.

### React

Wrap your app in `FeebloProvider`. It mounts the widget and hands control to its hooks.

```tsx
import { FeebloProvider } from "@feeblo/sdk-react";

<FeebloProvider organizationId="org_123" user={currentUser}>
  <App />
</FeebloProvider>;
```

Inside a child component, `useFeeblo` exposes `open`, `close`, `setBoard`, `openModule`, `metadata`, and `identify`, plus reactive `isOpen` and `isReady` values.

Config props such as `organizationId`, `mode`, `modules`, `placement`, `theme`, `defaultBoard`, `locale`, `baseUrl`, `containerStyles`, and `debug` tear down and remount the widget when they change. Treat them as configuration, not state. The `user` prop never remounts anything: changes call `identify` on the live widget, and the last identity replays if a config change recreates it.

## Attach the person behind the post

`identify` takes an `id` and optional `email`, `name`, `avatar`, `customFields`, and `companies`. Call it again when the details change. The last call wins.

Custom fields map to attributes you define in Feeblo. Values sent under keys with no matching definition are ignored. A definition marked required must be present in every identify call, or the identity fails validation.

A browser console can call `identify` too, which is why a signed token matters. Sign an HS256 JWT on your server with the organization secret, and Feeblo verifies it before it trusts the claims.

```ts
const token = jwt.sign(
  {
    sub: user.id,
    aud: process.env.FEEBLO_ORG_ID,
    exp: Math.floor(Date.now() / 1000) + 600,
    email: user.email,
    name: user.name,
    customFields: { plan: user.plan },
    companies: [{ id: company.id, name: company.name }],
  },
  process.env.FEEBLO_ORG_SECRET,
  { algorithm: "HS256" }
);
```

`sub`, `aud`, `exp`, `email`, and `name` are the claims Feeblo checks. Keep the token short-lived, in the 5 to 15 minute range. Mint it per page render or session, never in client-side code, and store the organization secret in your server environment.

The same token can sign the user into your public board. Add `data-feeblo-link` to an anchor and the SDK appends the token in the URL fragment, so it never reaches server logs, proxies, or the Referer header. A `?ssoToken=` redirect also works, but that URL does reach logs and history, so reserve it for redirects your server initiates.

On feeblo cloud, Widget SSO is included in the Starter and Professional plans.

## Under the widget: four endpoints

The embedded widget talks to four public routes under `/api/widget/v1`. Your backend can call the same routes and collect feedback without loading the SDK in a browser. None of them requires a key or a session, so anonymous visitors can browse and submit.

| Method | Route | Limit per client IP | What it does |
| --- | --- | --- | --- |
| `POST` | `/suggestions` | 5 per minute | Returns up to five similar public posts for a draft title and body |
| `POST` | `/feedback` | 20 per minute | Creates a post on a public board |
| `GET` | `/boards` | 120 per minute | Lists the public boards with names and slugs |
| `GET` | `/updates` | 120 per minute | Returns published changelog entries, newest first |

Suggestions is the duplicate check. Matching uses embeddings first and falls back to lexical scoring when the embedding backend is unavailable. That is why its budget is five requests per minute: each call runs a similarity search.

`POST /feedback` accepts `organizationId`, `boardId`, `title`, `content`, optional `metadata`, and an optional identity `token`. The title caps at 200 characters, the content at 20,000, and metadata at 20 string properties. The board must be public. A private board returns 400, and a missing board returns 404.

A successful submission fires the `feedback.post.created` webhook. If you send a token, Feeblo verifies it, binds it to your organization through its audience claim, upserts a contact from the claims, and attaches the post to that contact. Omit the token and the post stays anonymous.

`GET /updates` returns sanitized HTML in `content` and a cover image in `imageUrl`, which can be null. `GET /boards` never includes private boards.

Limits apply per client IP, per minute. Exceeding one returns 429. A 503 means the rate limiter itself is unreachable, so back off and retry. If you batch-import old feedback, keep every source IP under twenty `POST /feedback` calls per minute.

## The details that make an embed usable

- **Identity that survives the session.** Send an id, email, name, avatar, custom fields, and companies. Changes call `identify` on the live widget instead of remounting it.
- **Signed identity, not a guess.** Sign an HS256 JWT with your organization secret and pass it as `token`. Feeblo verifies the signature before it trusts the person.
- **Duplicates get caught early.** The suggestions endpoint searches public posts before submission.
- **Runs on your domain.** The overlay runs inside your app, and the public board lives on your subdomain. Set `baseUrl` when you self-host, and point `data-feeblo-link` at your own board.
- **Public by design.** The widget writes to public boards only. Private boards stay out of the board picker and out of the feedback endpoint.
- **Framework agnostic.** The core package ships ESM and UMD builds with no runtime dependencies. Trigger attributes work at the DOM level in any framework.

## The widget is not a black box

The SDK and the widget app live in the feeblo repository under AGPL-3.0. You can read how `identify` handles a token, how the iframe reports its height, and what the feedback endpoint does with metadata before you put it on a customer page.

Self-hosting moves the widget host too. Set `baseUrl` to the host that serves your widget, keep the org ID from your own dashboard, and the browser never calls feeblo.com.

What ships in the repo:

- The `@feeblo/sdk` package: init, identify, open, close, setBoard, and events.
- The `@feeblo/sdk-react` package: `FeebloProvider` and the `useFeeblo` hook.
- The four widget HTTP routes under `/api/widget/v1`.
- The iframe app that renders the feedback form and updates panel.
- The feedback endpoint that creates a post and fires `feedback.post.created`.

Feedback from the widget lands on the same board as feedback from the public page. One inbox, one status, one roadmap.

## Widget FAQ

### Do users need an account to leave feedback?

No. Anonymous submissions work, and the widget can open for anyone who can load your page. To attach a post to a known person, call `identify` with an id or pass a signed JWT, and Feeblo links the post to that contact.

### Does the widget work with React?

Yes. Install `@feeblo/sdk` and `@feeblo/sdk-react`, wrap your app in `FeebloProvider`, and use the `useFeeblo` hook for open, close, identify, and board changes. The React package re-exports the core SDK.

### Can I open the widget from my own button?

Yes. Add the `data-feeblo-feedback` attribute to any element and the SDK opens the widget on click. For full control, call `widget.open()`, or `feeblo.open()` from `useFeeblo` in React.

### Can the widget post to a private board?

No. `POST /api/widget/v1/feedback` accepts public boards only and returns 400 for a private board. `GET /api/widget/v1/boards` lists public boards, so a board picker never shows a private one.

### Can I self-host the widget?

Yes. The widget is part of the open-source repository, and the init options include `baseUrl` for the host that serves it. Point `baseUrl` at your own widget host and use the organization ID from your own dashboard.

### Is the widget included in the hosted plans?

The widget is part of the product, and Widget SSO is included in Starter and Professional. See https://feeblo.com/pricing for the current rows. Self-hosting carries no license fee under AGPL-3.0.

## Next

- Widget quickstart: https://docs.feeblo.com/developers/quickstart
- Widget configuration: https://docs.feeblo.com/developers/configuration
- Widget HTTP API: https://docs.feeblo.com/developers/api
- Self-host the widget: https://feeblo.com/self-hosted
- Open source license: https://feeblo.com/open-source
