Skip to content

Universal DevTools Kit SDK


Universal DevTools Kit SDK / @u-devtools/kit / define-plugin / definePlugin

Function: definePlugin() ​

definePlugin(options): DevToolsPlugin

Defined in: define-plugin.ts:123

Smart factory for creating DevTools plugins.

Automatically resolves paths for Dev (.ts) and Prod (.js) modes. Handles path resolution, file loading, and server setup automatically.

⚠️ Important: This function uses Node.js APIs (node:url, node:path) and should only be called in server-side code (Vite plugin context).

Import from @u-devtools/kit/define-plugin (not from @u-devtools/kit).

Parameters ​

ParameterTypeDescription
optionsDefinePluginOptionsPlugin configuration options

Returns ​

DevToolsPlugin

Configured DevToolsPlugin object

Example ​

ts
// In your plugin's index.ts (server-side)
import { definePlugin } from '@u-devtools/kit/define-plugin';

export default definePlugin({
  name: 'My Plugin',
  root: import.meta.url,  // Required!
  client: './client',      // Optional, defaults to './client'
  app: './app',            // Optional
  server: './server',      // Optional, defaults to './server'
  meta: {
    name: '@my-org/my-plugin',
    version: '1.0.0',
    description: 'My custom DevTools plugin'
  }
});

Released under the MIT License.