Guides
Upgrade to the hosted script and the new design
Load the plugin from one script tag, turn on the new design, and set up Appearance for a new or an existing embed.
Do this with your agent
embed-appearanceCheck whether our Databrain embed can use the hosted script and the new design. Show what would change and what to verify in staging. Keep our guest tokens, data scope and saved themes. Ask before applying changes.
Turn on the new design, set up Appearance (brand color, spacing, height, hide and named parts), and load the plugin from Databrain’s hosted script so your app gets plugin fixes without a redeploy. Each step is separate. Do only the ones you want.
Before you start
- Your app embeds a dashboard, or you are adding one. For a new embed, set up the guest token route first: Embed a dashboard.
- Your embed passes the tenancy check: every metric is scoped to the client, or shared on purpose. An upgrade does not change tenancy.
- Step 3 needs plugin 0.17.0 or later. Steps 4 to 7 need the plugin release listed in Changelog and versioning. To check the plugin that draws your embed, open a page with the embed in staging and run
customElements.get('dbn-dashboard')?.observedAttributes?.includes('sizing-mode')in the browser console.truemeans that release or later,falsemeans an older plugin. If it returnsundefined, the embed did not load: check again once it does. On an older plugin, skip those steps and keep your current design and settings. - Make the changes on a branch and test them in staging.
If you have an AI agent
An AI agent with the Databrain MCP server, such as Claude Code or Cursor in your repository, can do these steps for you. Ask it in your own words:
Upgrade our Databrain embed to the hosted script and the new design, and set up Appearance to match our brand.The agent checks your setup first. It warns you about each dashboard that changes in the new design and names the card. It changes only your app code, one commit for each step, so you can keep or drop each one. It does not change guest tokens, tenancy, saved themes or Databrain settings. It tells you which steps it skipped and what it could not verify, and ends with a pull request for your developer. Set up an embed with an AI agent shows how to connect it.
Check first
The new design changes how some cards work. Open each embedded dashboard in Preview as customer and look for these before step 3:
| What you have | What changes in the new design | What to do |
|---|---|---|
| A table that loads its rows page by page from the server, with Search or sort | With the new metric cards, Search is hidden on that table. Sort applies to the loaded page only. | Leave embed_ui_v2_metric_cards and embed_ui_v2_master off for that dashboard. Turn on the other parts one at a time. |
| A table your users search | With only embed_ui_v2_filters, the dashboard keeps its current cards and Search works. | Same as above. |
| A card with a setting the new cards or charts do not draw yet, such as a tooltip label or table color rules | The setting does not show in the new design. Turning on any part, even only the filters, also turns on the new charts. | Leave that dashboard on its current design, with no ui-version. |
| A card you could not check | You do not know yet. | Same as above, until you check it. |
| A page with more than one dashboard | One dashboard with ui-version="v2" turns on the new charts for the whole page. It can also switch a <dbn-metric> on that page. | Keep every dashboard on that page on its current design until all of them pass these checks. |
A <dbn-metric> on the same page as a <dbn-dashboard> with ui-version="v2" | The metric can switch to the new charts too. On some plugin releases, its axis numbers can change to the short form (12K). | Check the metric’s chart settings like a card in staging, and compare the numbers before and after. |
Steps
-
Load the plugin from the hosted script. Use this step only on Databrain cloud, after Databrain turns the hosted script on for your account. A page that uses proxy authentication keeps its token on your server, which the hosted script cannot read: keep step 2 for that page. Otherwise go to step 2.
Use the hosted script only on pages with embeds from one Databrain account. If a page has embeds from two accounts, keep using npm on that page.
A
200fromcurl -sI https://cdn.usedatabrain.com/loader/v1/loader.jsshows only that the file is there. Before you switch production, check a staging page with your app’s origin, region and guest token, with the npm registration import removed, in a fresh browser window. In the network panel,/loader/v1/manifeston your API host must answer200with JSON, and the browser must load a runtime named in that answer: itsurl, or itsfallback.urlin a browser that cannot check the files first. A dashboard drawn from any other runtime file is the built-in fallback.Add this tag once on each page with an embed:
<script src="https://cdn.usedatabrain.com/loader/v1/loader.js" async></script>- Remove only the import that registers the tags, for example
import '@databrainhq/plugin/web'. Keep the@databrainhq/pluginpackage if your code uses its types or@databrainhq/plugin/data. - Outside the US region, set
window.dbn.baseUrlbefore the tag, or adddata-api="https://<your API host>"to it. Abase-urlattribute on the element alone is read too late. - In your Content Security Policy, keep your API host in
connect-srcand addhttps://cdn.usedatabrain.comtoscript-srcandconnect-src. - Do not add an
integrityhash to this tag. The file changes between releases. The script checks the hash of every plugin file it loads. data-dbn-pin="<version>"asks for one published release. A pin Databrain sets for your account wins over it. During an outage, with no verified cached copy for this embed, the script can load the stable release built into it. If you need the same release every time, use step 2.
Keep step 2 as your rollback until the hosted script runs in production. If your app already pins the plugin, see Move from a pinned plugin version to the hosted script.
- Remove only the import that registers the tags, for example
-
Or use the npm package. Self-hosted Databrain uses this path, with the plugin version your release names. Keep your registration import, such as
import '@databrainhq/plugin/web', and install an exact version, with no^or~:npm install --save-exact @databrainhq/plugin@<version> # or: pnpm add --save-exact @databrainhq/plugin@<version> # or: yarn add --exact @databrainhq/plugin@<version>From 0.16.x to 0.17.0 or later, the plugin no longer writes the
configDataandishideSidebarkeys tolocalStorage. If your app reads them, listen for thedbn:embed-configevent instead: Handle embed events. -
Turn on the new design. Add
ui-versionandembed-flagsto<dbn-dashboard>.ui-version="v2"also turns on the new charts. Skip a dashboard that Check first leaves on its current design. For a dashboard with a table from Check first, name the parts instead ofembed_ui_v2_master, for example'{"embed_ui_v2_filters":true}'. The new design lists every part.<dbn-dashboard token="GUEST_TOKEN" dashboard-id="DASHBOARD_ID" ui-version="v2" embed-flags='{"embed_ui_v2_master":true}' ></dbn-dashboard> -
Use your brand color and compact spacing. Where you set them depends on your theme:
- With
theme-name, addadmin-theme-optionswith only these fields. They change only these fields, on this page. - With
admin-theme-optionsalready on the element, add these fields to it and keep the rest. - With neither, the embed uses your data app’s default theme, and a new
admin-theme-optionsreplaces it. Set Brand color, the Brand chart palette and compact density in the Theming screen instead. This changes every embed that uses that theme.
The fields:
{ "general": { "density": "compact" }, "dashboard": { "ctaColor": "#0F766E" }, "chart": { "selected": "Brand" } }"selected": "Brand"anddensityneed the plugin release above. That release makes a Brand palette from your brand color when your theme has no saved palette named Brand. On an older plugin, do not add them, and keep the chart palette and spacing your embed uses today, including aselectedvalue it already sets. Withtheme-name, an inlinectaColorneeds plugin 0.17.0 or later; older plugins use the named theme as it is.Match your brand adds the font and corner radius.
- With
-
Let the embed grow with its content. Add
sizing-mode="auto"and remove any fixed height on the element. If a parent box or an iframe must follow the height, listen fordbn-height-change. See Sizing. -
Use
hidein place of old hide options. For example,options='{"hideDashboardName":true}'becomeshide='{"dashboardName":true}'. Hide options maps each old flag to its key. Move a flag only when its key hides the same controls, and keep the other keys inoptions. Ahidekey wins over theenableoptions for its controls:downloadhides PNG, CSV, email CSV, ZIP and PDF, so to hide only PNG keepdisableDownloadPng. -
Use named parts in place of class names. Search your CSS and tests for class names from inside the embed, for example:
grep -rnE '\._[A-Za-z-]+_[a-z0-9]{5}_[0-9]+|\.dbn-[A-Za-z-]+|\.cta-primary' src testsThe search can also match your own class names. Change only selectors that reach into the embed. Before:
.dbn-card-element { border-radius: 12px; } ._popover_decz1_14 { border-color: #0F766E; }After:
dbn-dashboard::part(card) { border-radius: 12px; } :is(dbn-dashboard, dbn-metric, #dbn-portal, [data-dbn-embed-portal])::part(date-filter-menu) { border-color: #0F766E; }In tests, use
[part~="card"]. Pick the part for the exact element the old rule styled:.dbn-selectBox, for example, is thefilterwrapper on most filters and thefilter-labelon a number filter. Move to parts maps the most common class names, and Parts and states lists all 58 parts and the CSS each one takes. Keep a rule that has no part.
The embed loads from the hosted script or an exact npm version, in the new design, with your brand. Compare each embedded page before and after, signed in as the same test user.
If something goes wrong
- The embed shows “This page blocks the dashboard”. Your Content Security Policy blocks the host it names. Find the blocked host and directive in the browser console, and add it.
- A table lost its Search box. It loads rows from the server. Turn off
embed_ui_v2_metric_cardsandembed_ui_v2_masterfor that dashboard. - A part rule has no effect. Check that the plugin meets the release in Changelog and versioning, and that the property is in the part’s list.