--- title: Creating Your First Plugin summary: "Step-by-step guide to creating your first Beekeeper Studio plugin." icon: material/hammer-wrench --- # Creating Your First Plugin !!! warning "Beta Feature" The plugin system is in beta (available in Beekeeper Studio 5.3+). Things might change, but we'd love your feedback! Let's build a simple "Hello World" plugin! You'll create a new tab that shows "Hello World!" and learn how to interact with databases. Perfect for getting started! ๐ ## What You Need - Basic HTML, CSS, and JavaScript knowledge - Node.js and npm/yarn installed - Beekeeper Studio installed ## Quick Start (3 Options) ### Option 1: Vite Project โญ *Recommended* **Why Vite?** Vite provides a nice development experience with Hot Module Replacement (HMR). When you make changes to your plugin code, you'll see updates reflected in Beekeeper Studio without needing to manually reload the plugin or restart the application. This helps streamline the development process. Vite is also quite straightforward to configure. With a simple `vite.config.ts` and our official plugin, you get TypeScript support, modern JavaScript features, asset bundling, and production builds. #### 1. Create a Vite project === "npm" ```bash npm create vite@latest hello-world-plugin cd hello-world-plugin ``` === "yarn" ```bash yarn create vite hello-world-plugin cd hello-world-plugin ``` #### 2. Install the Beekeeper Studio Vite plugin === "npm" ```bash npm install @beekeeperstudio/vite-plugin ``` === "yarn" ```bash yarn add @beekeeperstudio/vite-plugin ``` #### 3. Create the manifest file Create `manifest.json` to define your plugin: ```json { "id": "hello-world-plugin", "name": "Hello World Plugin", "author": { "name": "Your Name", "url": "https://yourwebsite.com" }, "description": "My first awesome plugin!", "version": "1.0.0", "capabilities": { "views": [ { "id": "hello-world-tab", "name": "Hello World", "type": "shell-tab", "entry": "dist/index.html" } ] } } ``` #### 4. Create/update `vite.config.ts`: ```typescript import { defineConfig } from 'vite' import bks from '@beekeeperstudio/vite-plugin' export default defineConfig({ plugins: [bks()], }) ``` #### 5. Link to Beekeeper Studio Create a symbolic link so Beekeeper Studio can find your plugin: === "Linux" ```bash ln -s $(pwd) ~/.config/beekeeper-studio/plugins/hello-world-plugin ``` === "macOS" ```bash ln -s $(pwd) "~/Library/Application Support/beekeeper-studio/plugins/hello-world-plugin" ``` === "Windows" ```cmd mklink /D "%APPDATA%\beekeeper-studio\plugins\hello-world-plugin" "%CD%" ``` === "Portable Version" ```bash ln -s $(pwd) /path/to/beekeeper-studio/beekeeper-studio-data/plugins/hello-world-plugin ``` !!! tip "Why link instead of copying directly?" This keeps your code safe! If you accidentally uninstall the plugin, your source code won't be deleted. #### 6. Run development server === "npm" ```bash npm run dev ``` === "yarn" ```bash yarn dev ``` Now you have hot reload! Changes to your code will automatically update in Beekeeper Studio. --- ### Option 2: Use the Starter Template (without Vite) #### 1. Clone our ready-to-go template ```bash git clone https://github.com/beekeeper-studio/bks-plugin-starter.git hello-world-plugin cd hello-world-plugin ``` #### 2. Link it to Beekeeper Studio's plugins folder === "Linux" ```bash ln -s $(pwd) ~/.config/beekeeper-studio/plugins/hello-world-plugin ``` === "macOS" ```bash ln -s $(pwd) "~/Library/Application Support/beekeeper-studio/plugins/hello-world-plugin" ``` === "Windows" ```cmd mklink /D "%APPDATA%\beekeeper-studio\plugins\hello-world-plugin" "%CD%" ``` !!! tip "Why link instead of copying directly?" This keeps your code safe! If you accidentally uninstall the plugin, your source code won't be deleted. --- ### Option 3: Build from Scratch Want to understand every piece? Let's build it step by step: #### Step 1: Create Your Plugin Folder First, create a folder anywhere you like for your plugin: ```bash mkdir hello-world-plugin cd hello-world-plugin ``` Then link it to Beekeeper Studio's plugins directory: === "Linux" ```bash ln -s $(pwd) ~/.config/beekeeper-studio/plugins/hello-world-plugin ``` === "macOS" ```bash ln -s $(pwd) "~/Library/Application Support/beekeeper-studio/plugins/hello-world-plugin" ``` === "Windows" ```cmd mklink /D "%APPDATA%\beekeeper-studio\plugins\hello-world-plugin" "%CD%" ``` === "Portable Version" ```bash ln -s $(pwd) /path/to/beekeeper-studio/beekeeper-studio-data/plugins/hello-world-plugin ``` !!! tip "Why link instead of copying directly?" This keeps your code safe! If you accidentally uninstall the plugin, your source code won't be deleted. #### Step 2: Create the Manifest Create `manifest.json` - this tells Beekeeper Studio about your plugin: ```json { "id": "hello-world-plugin", "name": "Hello World Plugin", "author": { "name": "Your Name", "url": "https://yourwebsite.com" }, "description": "My first awesome plugin!", "version": "1.0.0", "capabilities": { "views": [ { "id": "hello-world-tab", "name": "Hello World", "type": "shell-tab", "entry": "index.html" } ] } } ``` #### Step 3: Create the Interface Create `index.html` - your plugin's main page: ```html
Edit this HTML and reload to see changes.
` tag): ```html
```  ## Theme Sync (Optional) ๐จ !!! note "Coming Soon!" Automatic theme syncing is planned. For now, here's how to do it manually. Make your plugin match Beekeeper Studio's theme: **Add to your `main.js`:** ```javascript import { addNotificationListener } from "./node_modules/@beekeeperstudio/plugin/dist/index.js"; // Sync with app theme addNotificationListener("themeChanged", (args) => { const css = `:root { ${args.cssString} }`; let style = document.getElementById("bks-theme-style"); if (style) { style.innerHTML = css; } else { style = document.createElement("style"); style.id = "bks-theme-style"; style.innerHTML = css; document.head.appendChild(style); } }); ``` **Update your CSS to use theme variables:** ```css body { background-color: var(--query-editor-bg, #f8f9fa); color: var(--text-dark, #333); } button { background-color: var(--theme-base, #3182ce); color: white; } .tables { background-color: var(--brand-success-light, #e6fffa); } ``` The fallback values (after the comma) ensure your plugin works even before theme sync is initialized. ## Final Result ๐ **Your complete `index.html`:** ```htmlEdit this HTML and reload to see changes.