Framework Integration
Pick your framework
Embed a Databrain dashboard or metric in the framework your app uses.
@databrainhq/plugin gives you two custom elements: <dbn-dashboard> and <dbn-metric>. They work in any framework.
| Your app | Guide |
|---|---|
| React | Embed in React |
| Next.js | Embed in Next.js |
| Vue 3 | Embed in Vue |
| Angular | Embed in Angular |
| Svelte 5 | Embed in Svelte |
| Solid | Embed in Solid |
| No framework | Embed with JavaScript |
Before you start
- Your backend has an endpoint that returns a guest token. The guides call it
/api/databrain-token. Create a guest token - You have the id of a dashboard or a metric. Find the dashboard id
Keep your data app API key on your backend. Never put it in browser code.
Rules for every framework
- Install with
npm install @databrainhq/plugin. npm also installsreactandreact-dom, which the plugin needs. - Import
@databrainhq/plugin/webonce, in browser code only. The import registers the elements. - Write attributes in kebab case:
dashboard-id,metric-id,enable-download-csv. - Turn a boolean on with the value
"true". A bare attribute reads as off. - Pass an object as a JSON string attribute, or as a JS property.
- Set a function, such as
handleServerEvent, as a JS property on the element. Assign an inline arrow function. - To show a different dashboard, remount the element. Each guide uses a key for this.
All props are in the component options reference.