# Custom widgets overview

A custom widget is a small front-end app you package as a ZIP and upload to Bito. You can run it privately in your own account, or publish it after both its executable release and marketplace card pass moderation. Bito serves the approved files and loads them into the admin panel, where your code renders inside the product's own screens: a tab on a customer profile, an entry in a phone-number menu, an always-on background widget, or its own settings page.

If you have written an amoCRM widget, the shape will be familiar: `script.js` is an AMD module that returns a `CustomWidget` constructor with a `callbacks` object, and it is handed jQuery 4 as `$`.

::: danger A widget runs with the signed-in user's access
Your `script.js` is loaded with a plain `<script src>` and **executes in the admin panel's own origin and session**, as part of the product. Use only the data and calls your feature needs.

The tenant decides on **the per-release consent screen**. A tenant installing your widget is trusting you — the developer — with everything the signed-in user can do, including trade, finance and payroll data. Bito reviews submissions; it does not guarantee third-party code.
:::

This replaces the older iframe widget, where your own hosted page was embedded in an iframe on the integration's settings tab. That settings-tab mechanism still exists (`iframe.url` plus a [one-time token](https://docs.bito.uz/en/guide/oauth/one-time-tokens.md)), but it is not how a custom widget works.

## The shape of it

```text
  Developer                        Bito                          Tenant
      |                              |                              |
      |  1. Build widget.zip         |                              |
      |  2. Complete the app card,   |                              |
      |     create a release,        |                              |
      |     upload the archive       |                              |
      |----------------------------->|                              |
      |     validation report        |                              |
      |<-----------------------------|                              |
      |  3. Test locally, then       |                              |
      |     submit release review    |                              |
      |----------------------------->|                              |
      |                              |  4. Release moderation       |
      |                              |     approve -> assets        |
      |                              |     extracted + runnable     |
      |  5. Submit card review       |                              |
      |<-----------------------------|                              |
      |                              |  6. Card approval -> public  |
      |                              |  7. Tenant installs          |
      |                              |<-----------------------------|
      |                              |  8. Boss accepts the         |
      |                              |     consent for THIS release |
      |                              |<-----------------------------|
      |                              |  9. mount -> script.js runs  |
      |                              |     in the admin panel       |
```

## Where the files are served from

Approved assets are extracted and served from a **separate registrable domain**, not a `bito.uz` subdomain. That buys cookie isolation and a smaller cache blast radius. It does not change where your code runs: a cross-origin `<script src>` executes in the page that loaded it, which is the point of this model.

Files are served with `X-Content-Type-Options: nosniff` and a content type assigned server-side from the extension allowlist, never from anything you send.

## Consent is per release

A tenant's acceptance is bound to the exact release they accepted. Publishing a new approved version re-prompts every tenant, because the code being trusted has changed. Until the prompt is accepted, `mount` refuses and your widget does not run.

Only a **boss or additional boss** can accept — an ordinary employee sees who must. Acceptance records who accepted and when, and the tenant can revoke it, which unmounts the widget everywhere.

## What a widget is made of

| File | Required | Purpose |
|---|---|---|
| `manifest.json` | Yes | Interface version, declared languages, mount surfaces, disclosed destinations |
| `script.js` | Yes | The AMD module returning your `CustomWidget` |
| `i18n/<lang>.json` | One per declared language | Flat key → string bundle, resolved server-side |
| `style.css` | No | Injected into the host document as a `<link>` |
| `templates/` | No | Named templates for `bito.render()` |
| `images/` | No | Static assets |

Full rules and limits: [the widget.zip format](https://docs.bito.uz/en/guide/widget-package.md).

## Read next

| Page | What it answers |
|---|---|
| [The widget.zip format](https://docs.bito.uz/en/guide/widget-package.md) | What goes in the archive and what gets it rejected |
| [The CustomWidget lifecycle](https://docs.bito.uz/en/guide/widget-lifecycle.md) | Which callbacks run, in what order, and what happens when one throws |
| [The bito SDK](https://docs.bito.uz/en/guide/widget-sdk.md) | Every method on `window.bito` |
| [Mount surfaces](https://docs.bito.uz/en/guide/widget-surfaces.md) | Where in the product your widget can appear |
| [jQuery compatibility](https://docs.bito.uz/en/guide/widget-jquery.md) | What is replaced in the bundled jQuery 4 |
| [Publishing a release](https://docs.bito.uz/en/guide/widget-release.md) | Versions, the review queue, what approval changes |
| [Your app page](https://docs.bito.uz/en/guide/developer-app.md) | The separate marketplace-card and release workflows |
| [Becoming a Bito developer](https://docs.bito.uz/en/guide/developer-account.md) | How to get an account that can do any of this |
