NetPad Extensions
NetPad's extension system allows you to add custom functionality to your NetPad installation through modular, independently deployable packages. Extensions can provide API routes, UI components, services, middleware, and more.
What Are Extensions?โ
Extensions are npm packages that follow the NetPadExtension interface. They integrate seamlessly with NetPad's core functionality while remaining isolated and independently maintainable.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ NetPad Core โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โ โ Extension โ โ Extension โ โ Extension โ ... โ
โ โ (Cloud) โ โ(Collaborate)โ โ (Custom) โ โ
โ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
Extension Capabilitiesโ
Extensions can provide:
| Capability | Description |
|---|---|
| Routes | Custom API endpoints under /api/ext/{extension-name}/ |
| Services | Shared business logic accessible throughout the extension |
| Middleware | Request/response processing with priority ordering |
| Components | React UI components for use in pages |
| Features | Feature flags that enable/disable functionality |
| Lifecycle Hooks | Initialize and cleanup logic |
Built-in Extensionsโ
NetPad includes several built-in extensions:
@netpad/cloud-featuresโ
The cloud features extension provides premium functionality for NetPad Cloud:
- Billing & Subscriptions - Stripe integration for payments
- Atlas Provisioning - Automatic MongoDB cluster creation
- Premium AI Features - Advanced RAG and AI capabilities
- Usage Analytics - Detailed usage tracking and reporting
@netpad/collaborateโ
Community collaboration features:
- Gallery - Community showcase of forms, workflows, and integrations
- Contributors - Leaderboard and contributor profiles
- Submissions - Collaboration application system
- UI Components - Pre-built React components
@netpad/demo-nodeโ
A beginner-friendly demonstration extension:
- Log Message Node - A simple workflow node for debugging
- Extensively Commented - Learn by reading the source code
- Template Ready - Copy and modify for your own extensions
See Example: Demo Node Extension for a complete walkthrough.
Extension Architectureโ
Extensions follow a clear architectural pattern:
// Extension structure
const myExtension: NetPadExtension = {
metadata: {
id: 'my-extension',
name: 'My Extension',
version: '1.0.0',
description: 'Description of what this extension does',
},
// Features this extension provides
features: ['custom:my_feature'],
// API routes
routes: [
{ path: '/api/ext/my-extension/data', method: 'GET', handler: handleGet },
{ path: '/api/ext/my-extension/data', method: 'POST', handler: handlePost },
],
// Request middleware
middleware: [
{ path: '/api/ext/my-extension/*', handler: authMiddleware, priority: 10 },
],
// Shared services
services: {
myService: myServiceInstance,
},
// Lifecycle hooks
initialize: async () => { /* Setup logic */ },
cleanup: async () => { /* Cleanup logic */ },
};
Quick Startโ
1. Enable an Extensionโ
Add the extension package name to your .env.local:
# Enable single extension
NETPAD_EXTENSIONS=@netpad/collaborate
# Enable multiple extensions
NETPAD_EXTENSIONS=@netpad/collaborate,@myorg/custom-extension
2. Install the Packageโ
npm install @netpad/collaborate
3. Restart NetPadโ
Extensions are loaded during application startup.
Creating Custom Extensionsโ
Ready to build your own extension? You have two options:
Option 1: Use the MCP Server (Recommended for Quick Start)โ
If you're using an AI assistant like Claude Desktop or Cursor IDE with the NetPad MCP Server, you can generate complete extension packages with natural language:
"Create a NetPad extension with a custom workflow node that sends SMS messages"
The AI will generate all necessary files including package.json, TypeScript source, and documentation. See the MCP Server documentation for setup instructions.
Option 2: Build Manuallyโ
For more control, build your extension from scratch using these guides:
- Extension Architecture - Deep dive into extension internals
- Building Extensions - Step-by-step tutorial
- Workflow Node Extensions - Creating custom workflow nodes
- API Reference - Complete API documentation
Examplesโ
- Example: Demo Node Extension - Start here! Beginner-friendly walkthrough
- Example: Collaborate Extension - Production-ready example
Extension Loadingโ
Extensions are loaded in this order:
- Cloud Extension -
@netpad/cloud-features(ifNETPAD_CLOUD=true) - Plugin Extensions - Packages listed in
NETPAD_EXTENSIONS - Programmatic Extensions - Registered via
registerExtensionManually()
Each extension goes through:
- Package resolution and import
- Registration in the extension registry
- Initialization via the
initialize()hook
Feature Checkingโ
Extensions can declare features that other parts of the application can check:
import { isFeatureAvailable } from '@/lib/extensions/registry';
// Check if a feature is available
if (isFeatureAvailable('billing')) {
// Show billing UI
}
// Custom extension features use the custom: prefix
if (isFeatureAvailable('custom:collaborate')) {
// Show collaborate features
}
Best Practicesโ
- Use descriptive metadata - Clear names and descriptions help users understand your extension
- Namespace your routes - Always use
/api/ext/{your-extension}/for routes - Handle errors gracefully - Extensions should not crash the main application
- Clean up resources - Implement the
cleanup()hook for proper teardown - Document your extension - Provide clear usage instructions and API documentation
Next Stepsโ
- Example: Demo Node Extension - Best starting point for beginners
- Extension Architecture - Understand how extensions work internally
- Building Extensions - Create your first extension
- Workflow Node Extensions - Add custom workflow nodes
- API Reference - Complete API documentation