---
title: "Widgets"
description: "Hosted HTML or external URL pages for the home dashboard and sidebar."
canonical_url: "https://docs.vettero.com/build/widgets"
---
# Widgets

> Hosted HTML or external URL pages for the home dashboard and sidebar.

**Widgets** are custom workspace pages that run in a sandboxed iframe. Content is either **hosted HTML** (with `window.vt` injected) or an **external URL** that uses the same protocol. Bind queries, functions, agents, workflows, and blocks — then call them from the iframe without exposing workspace credentials.

Use them for interactive dashboards, ops consoles, and custom forms on the home grid or as sidebar pages. These are **not** [chat widgets](https://docs.vettero.com/build/chat-widgets) (Liquid UIs inside chat messages).

## When to use

- Build custom workspace pages that need live table data or long-running jobs
- Reuse the same queries, functions, agents, and workflows from the browser
- Place the UI on the dashboard and/or as one or more sidebar pages

The iframe never gets raw API keys. Only keys listed under **Bound resources** and **Jobs** are callable through `vt`.

## Create a widget

Open **Build → Widgets** and click **New**.

1. Enter a **Name** and optional **Description**.
2. Click create — Vettero creates a **Hosted** widget and opens the editor.

On the list, filter by **All**, **Hosted**, or **URL**. Widgets are workspace-only; there is no agent-scoped iframe widget panel.

## Configure the widget

From the widget detail page, click **Edit**.

<table>
<thead>
  <tr>
    <th>
      Section
    </th>
    
    <th>
      What you configure
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Name
      </strong>
      
       / <strong>
        Description
      </strong>
    </td>
    
    <td>
      Identity in lists and Studio
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Source
      </strong>
    </td>
    
    <td>
      <strong>
        Hosted HTML
      </strong>
      
       or <strong>
        External URL
      </strong>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        HTML document
      </strong>
      
       or <strong>
        URL
      </strong>
    </td>
    
    <td>
      Full HTML when hosted; required URL when external
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Input args schema
      </strong>
    </td>
    
    <td>
      JSON Schema for instance args → <code>
        vt.getArgs()
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Bound resources
      </strong>
    </td>
    
    <td>
      One-shot calls via <code>
        vt.run*
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Jobs
      </strong>
    </td>
    
    <td>
      Long-running runs via <code>
        vt.startJob
      </code>
      
       / watch / cancel
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Preview
      </strong>
    </td>
    
    <td>
      Live preview of the widget
    </td>
  </tr>
</tbody>
</table>

For hosted widgets, the `vt` SDK is injected before `</body>`. New hosted widgets without custom HTML get a default document that demos theme helpers and `vt.getArgs()`.

## Add integrations

On the widget detail page, open **Integrations**. Each integration is a placement with its own args, access control, and where it can appear.

<table>
<thead>
  <tr>
    <th>
      Setting
    </th>
    
    <th>
      What it does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Name
      </strong>
    </td>
    
    <td>
      Label in the sidebar or dashboard picker
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Show in
      </strong>
    </td>
    
    <td>
      <strong>
        Sidebar
      </strong>
      
      , <strong>
        Dashboard
      </strong>
      
      , or both
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Icon
      </strong>
    </td>
    
    <td>
      Optional icon
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Access roles
      </strong>
    </td>
    
    <td>
      Who can open it; empty = all roles
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Input args
      </strong>
    </td>
    
    <td>
      Values matching the widget’s input schema (<code>
        vt.getArgs()
      </code>
      
      )
    </td>
  </tr>
</tbody>
</table>

**Sidebar** integrations appear in the sidebar pool. Members place them under **Workspace Settings → Sidebar Items** (type **Widget**).

**Dashboard** integrations appear on **Home**. Each member adds or removes the tiles they are allowed to see. The tile uses the integration’s args; members do not type their own. A role that is not listed cannot add that tile, and a tile they already had disappears if they lose access.

With no integrations, the widget is not listed in the sidebar or on the dashboard.

## Bind resources and jobs

### Bound resources (one-shot)

Same pattern as [functions](https://docs.vettero.com/build/functions): unique keys, then call with `vt.runQuery`, `vt.runFunction`, `vt.runWorkflow`, `vt.runAgent`, or `vt.runBlock`.

<table>
<thead>
  <tr>
    <th>
      Type
    </th>
    
    <th>
      Notes
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Query
      </strong>
    </td>
    
    <td>
      Any workspace query
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Function
      </strong>
    </td>
    
    <td>
      Any workspace function
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Agent
      </strong>
      
       / <strong>
        Workflow
      </strong>
    </td>
    
    <td>
      Must use the <strong>
        general
      </strong>
      
       channel
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Block
      </strong>
    </td>
    
    <td>
      Tool-capable block; pick a <strong>
        Service
      </strong>
      
       when needed
    </td>
  </tr>
</tbody>
</table>

`runAgent` / `runWorkflow` wait for completion (up to about 5 minutes) and throw if the run fails or is waiting for human approval. `runBlock` does not support human-in-the-loop interrupts.

### Jobs (async)

Jobs are for long-running work. Add a key, type (**Workflow**, **Agent**, or **Function**), target, and scope:

<table>
<thead>
  <tr>
    <th>
      Scope
    </th>
    
    <th>
      Meaning
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Per user
      </strong>
    </td>
    
    <td>
      One active run per caller
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Global
      </strong>
    </td>
    
    <td>
      One shared active run per job key
    </td>
  </tr>
</tbody>
</table>

Starting a job while one is already active for that scope fails with **Job already running**. Status values: pending, running, finished, failed, cancelled. Jobs cannot bind **Query** or **Block**.

## Match the workspace theme

Hosted widgets receive the current workspace theme as CSS variables, including the company primary color and dark mode. Use the built-in classes for cards and controls. Use the variables when you need custom layout. Do not hardcode colors.

<table>
<thead>
  <tr>
    <th>
      Class
    </th>
    
    <th>
      What it is
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        vt-grid
      </code>
    </td>
    
    <td>
      Auto-fit card grid
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-card
      </code>
    </td>
    
    <td>
      Bordered panel
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-label
      </code>
      
       / <code>
        vt-value
      </code>
    </td>
    
    <td>
      Metric label and value
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-muted
      </code>
    </td>
    
    <td>
      Secondary text
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-btn
      </code>
      
       / <code>
        vt-btn-primary
      </code>
    </td>
    
    <td>
      Buttons
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt-input
      </code>
    </td>
    
    <td>
      Text input
    </td>
  </tr>
</tbody>
</table>

Variables include `--vt-bg`, `--vt-surface`, `--vt-surface-muted`, `--vt-border`, `--vt-text`, `--vt-text-muted`, `--vt-primary`, `--vt-primary-contrast`, `--vt-radius`, and `--vt-space`. They update when the theme changes. `vt.getTokens()` returns the same values if a script needs them.

```html
<div class="vt-grid">
  <div class="vt-card">
    <div class="vt-label">Total balance</div>
    <div class="vt-value">—</div>
  </div>
</div>
```

## Use the widget SDK

Hosted widgets get `window.vt` automatically. URL widgets must speak the same `vettero-widget` postMessage protocol (or load the same SDK).

<table>
<thead>
  <tr>
    <th>
      Method
    </th>
    
    <th>
      What it does
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <code>
        vt.getArgs()
      </code>
    </td>
    
    <td>
      Instance args from the sidebar or dashboard integration
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        vt.isDark()
      </code>
      
       / <code>
        vt.getTokens()
      </code>
      
       / <code>
        vt.onThemeChange(cb)
      </code>
    </td>
    
    <td>
      Theme flag, current design tokens, and a listener <code>
        cb(dark, tokens)
      </code>
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        await vt.getUser()
      </code>
    </td>
    
    <td>
      Current user profile
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        await vt.runQuery
      </code>
      
       / <code>
        runFunction
      </code>
      
       / <code>
        runWorkflow
      </code>
      
       / <code>
        runAgent
      </code>
      
       / <code>
        runBlock
      </code>
    </td>
    
    <td>
      Bound resources
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        await vt.watchQuery(key, input?, onData)
      </code>
    </td>
    
    <td>
      Re-runs when related table rows change
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        await vt.startJob
      </code>
      
       / <code>
        getJob
      </code>
      
       / <code>
        getCurrentJob
      </code>
      
       / <code>
        listJobs
      </code>
      
       / <code>
        cancelJob
      </code>
    </td>
    
    <td>
      Job lifecycle
    </td>
  </tr>
  
  <tr>
    <td>
      <code>
        await vt.watchJob(key, runId?, onUpdate)
      </code>
    </td>
    
    <td>
      Watch a job; omit <code>
        runId
      </code>
      
       to watch the current run
    </td>
  </tr>
</tbody>
</table>

<tip>

Use `vt.runQuery` to run a bound query. Add `vt.watchQuery` to watch for related table-row changes and make a **live widget**.

</tip>

```html
<script>
  async function load() {
    const args = vt.getArgs()
    const { rows, total } = await vt.runQuery('orders', { status: args.status })
    const job = await vt.startJob('sync', { status: args.status })
    console.log(total, job.status)
  }
  load()
</script>
```

## Place on the home dashboard

On **Home**, use **Add widget** / **Manage widgets** to pin widgets as tiles. Each tile can pass its own args matching the input schema.

## Limits

- Agents and workflows bound as resources or jobs must use the **general** channel.
- Jobs cannot bind query or block types.
- A second `startJob` while an active run exists for that scope fails.

## Where widgets are used

<table>
<thead>
  <tr>
    <th>
      Place
    </th>
    
    <th>
      How
    </th>
  </tr>
</thead>

<tbody>
  <tr>
    <td>
      <strong>
        Home dashboard
      </strong>
    </td>
    
    <td>
      Tile with the widget and optional args
    </td>
  </tr>
  
  <tr>
    <td>
      <strong>
        Sidebar
      </strong>
    </td>
    
    <td>
      Each <strong>
        Sidebar integration
      </strong>
      
      , or <strong>
        Settings → Sidebar Items
      </strong>
    </td>
  </tr>
</tbody>
</table>


## Sitemap

See the full [sitemap](https://docs.vettero.com/sitemap.md) for all pages.
