Skip to content

Plugin SDK

Beekeeper Studio provides two open source packages for building plugins:

Package What it does Links
Beekeeper Studio Plugin SDK (@beekeeperstudio/plugin) TypeScript SDK your plugin uses to talk to Beekeeper Studio GitHub · npm · SDK Reference
Vite build plugin (@beekeeperstudio/vite-plugin) Hot reloading during development and production builds for Beekeeper Studio GitHub · npm

Both packages are MIT licensed.

Beekeeper Studio Plugin SDK

Plugins run in a sandboxed <iframe> and talk to Beekeeper Studio with postMessage. The SDK wraps those messages in typed, promise-based functions, so you don't have to handle the message protocol yourself.

Installation

npm install @beekeeperstudio/plugin
yarn add @beekeeperstudio/plugin

Usage

// Forwards keyboard and mouse events to Beekeeper Studio
import "@beekeeperstudio/plugin/dist/eventForwarder";
import { getTables, runQuery } from "@beekeeperstudio/plugin";

// Get all tables in the current database
const tables = await getTables();

// Run a SQL query
const result = await runQuery("SELECT * FROM users LIMIT 10");

Features

The SDK Reference documents every function, event and type.

Vite Build Plugin

@beekeeperstudio/vite-plugin is the recommended way to build a plugin with Vite. It:

  • Enables hot module replacement inside Beekeeper Studio during development
  • Rewrites your HTML for production builds so bundled assets load correctly in the app

You still use the SDK in your plugin code; the build plugin only changes how it is built and served.

Installation

npm install --save-dev @beekeeperstudio/vite-plugin
yarn add -D @beekeeperstudio/vite-plugin

Configuration

Add it to vite.config.ts:

import { defineConfig } from "vite";
import bks from "@beekeeperstudio/vite-plugin";

export default defineConfig({
  plugins: [bks()],
});

By default it transforms index.html into dist/index.html, which matches a view entry of dist/index.html in your manifest. If your plugin has more than one HTML page, list each one with the entrypoints option:

export default defineConfig({
  plugins: [
    bks({
      entrypoints: [
        { input: "index.html", output: "dist/index.html" },
        { input: "config.html", output: "dist/config.html" },
      ],
    }),
  ],
});

Next Steps