Plugin system just shipped — see what's next on the roadmap
dbcooldbcool
← Back to blog
A deep-dive into the dbcool plugin system
pluginstutorial

A deep-dive into the dbcool plugin system

Dominik Bucher·

Plugins in dbcool

A dbcool plugin is a small web application (a single HTML file, or a bundled JS/TS project) that runs sandboxed in an iframe and talks to the host through window.dbcoolAPI. Every call is async and re-checked against the plugin's granted permissions on the host side — a plugin never gets raw access to your tables, only to the specific data slots its manifest declares and you approved.

Cell plugins

Cell plugins render inside a table cell. They can read and write the cell's value, respond to host-driven changes, and ask for more vertical space. A minimal vanilla JS cell plugin looks like this:

js
function ready(callback) {
  if (window.dbcoolAPI) return callback();
  window.addEventListener("dbcool:apiReady", callback, { once: true });
}

ready(async () => {
  const api = window.dbcoolAPI;
  const root = document.getElementById("root");

  async function render() {
    const value = (await api.getValue()) ?? "(empty)";
    root.textContent = value;
  }

  // Re-render whenever the host pushes a new value
  window.addEventListener("dbcool:valueChanged", render);
  await render();
});

The bridge is injected into the iframe after it loads, so a plugin waits for window.dbcoolAPI (or the dbcool:apiReady event) before calling anything. From there, getValue(), setValue(), and finishEdit() cover the basic read/write/commit cycle for a cell.

Tab plugins

Tab plugins occupy a full page instead of a cell. They use the same bridge with a couple of tab-specific calls (getConfig()/setConfig()), plus the same declared-data-slot access as cell plugins — getRows(), addRow(), updateRow() against whatever the manifest requests and you approved.

Getting started

The example plugins ship in the repo under plugins/example-* — a text cell, a diagram cell, and a graph cell are the fastest way to see a working manifest and bridge calls side by side.