Plugins
Learn how to create and use plugins to extend Motia's functionality
Plugins
Plugins are a powerful way to extend Motia's functionality by adding custom features to the workbench, and integrating with external services.
What are Plugins?
Plugins in Motia allow you to:
Custom Workbench Tabs
Specialized Visualizations
Service Integrations
Core Extensions
Reusable Modules
Motia comes with several official plugins like plugin-logs, plugin-endpoint, plugin-observability, and plugin-states that demonstrate the power and flexibility of the plugin system.
Plugin Architecture
Core Types
Plugins are built using three main TypeScript types:
MotiaPlugin
The main plugin configuration returned by your plugin function:
WorkbenchPlugin
Configuration for a workbench tab:
MotiaPluginContext
Context object provided to your plugin with access to Motia's internal APIs:
Creating a Plugin
Quick Start with CLI
The fastest way to create a new plugin is using the Motia CLI:
After creation, set up and verify the build pipeline:
What the CLI template includes
- TypeScript and React configuration
- Vite build setup
- Example workbench UI component
- Required dependencies pre-installed
- Ready-to-build project structure
Manual Setup
If you prefer to set up manually or want to understand the structure, follow these steps:
Create a new directory for your plugin with the following structure:
Create a package.json with proper exports for both the main entry and plugin definition:
Create src/plugin.ts to define your plugin:
Create your React component in src/components/example-page.tsx:
Create src/index.ts to export your components:
Create src/styles.css to import Motia's UI styles:
Vite configuration — Create vite.config.ts:
PostCSS configuration — Create postcss.config.js:
TypeScript configuration — Create tsconfig.json:
Add build scripts to your package.json:
Then run the build:
Local Plugins
Local plugins provide a simpler alternative to creating full distributable packages when you want to add custom functionality specific to your project. Unlike publishable plugins, local plugins don't require building, packaging, or separate dependencies—they live directly in your project directory.
When to Use Local Plugins
Local plugins are ideal for:
Development & prototyping
Project-specific features
Internal tooling
Learning environment
The ~/ Package Name Syntax
Local package resolution with ~/
The ~/ prefix in packageName tells Motia to load components from your local project directory instead of node_modules:
Motia resolves ~/ to your project root, so you can import components without publishing them as registry packages.
Creating a Local Plugin
Create a simple structure in your project:
In motia.config.ts, create a plugin function that returns the plugin configuration:
Create plugins/index.tsx with your component:
Including Custom Steps
Include custom steps
Local plugins can also include custom steps by specifying a dirname and steps pattern:
This loads API routes, event handlers, and other step types directly from the plugin directory.
Best Practices for Local Plugins
Keep components simple
Use TypeScript
Organize by feature
Reuse dependencies
Document your APIs
When to Migrate to NPM Plugin
When to publish as a distributable package
- You want to share it across multiple projects
- It provides general-purpose functionality
- You need versioning and dependency management
- The plugin is stable and well-tested
Using Plugins
Installing a Plugin
Configuring Multiple Plugins
Configure multiple plugins
Registering Custom APIs
Register custom APIs
Use the registerApi method from the plugin context:
Example Plugin
Example plugin reference
A complete minimal example plugin lives at plugins/plugin-example in the Motia repository. It demonstrates:
- Basic plugin structure
- Workbench tab integration
- UI component creation
- Build configuration
- TypeScript setup
Use it as a starting point for your own plugins.
Troubleshooting
Plugin not showing in workbench
- Check that the plugin is imported in
motia.config.ts - Verify the
componentNamematches your exported component - Ensure the plugin is built (
pnpm run build) - Check browser console for errors
Styles not loading
- Verify CSS is imported in
src/index.ts - Check that
styles.cssis exported inpackage.json - Ensure TailwindCSS is properly configured
- Confirm that
cssImportsis defined insrc/plugin.tswith the path to the built CSS file (e.g.,['@motiadev/plugin-example/dist/plugin-example.css'])
Resolving type errors
- Make sure
@motiadev/coreand@motiadev/uiare listed inpeerDependencies - Run
pnpm installso TypeScript picks up the types - Confirm
declaration: trueis set intsconfig.json
Next Steps
- Explore the plugin-logs source code for a complete example