Plugins

Build powerful, reusable modules that extend Baasix with custom schemas, routes, hooks, services, and more. Package your logic once, use everywhere — from authentication providers to payment integrations to AI capabilities.

7+
Plugin Types
Custom Logic
NPM
Publishable
TypeScript
Native

Modular Architecture, Unlimited Possibilities

Plugins are self-contained modules that seamlessly integrate with the Baasix core.

Unlike simple extensions, plugins are full-featured modules that can add database schemas, register API routes, intercept operations with hooks, provide reusable services, run scheduled tasks, and inject middleware. Everything is automatically discovered and initialized — just import and register. Build it once, share via npm, and use across all your projects.

  • Add schemas: create new database collections/tables
  • Add routes: register custom API endpoints with full control
  • Add hooks: run code before/after CRUD operations
  • Add services: provide reusable business logic
  • Add schedules: run tasks on a cron schedule
  • Add middleware: inject Express middleware for custom processing
  • Full TypeScript support with typed context and services
  • Publish to npm and share across projects

Define Once, Use Everywhere

Creating a plugin is straightforward. Define your functionality, export it, and register with your server.

import { definePlugin } from '@tspvivek/baasix';

export function myPlugin(config: MyPluginConfig) {
  return definePlugin({
    meta: {
      name: 'my-plugin',
      version: '1.0.0',
      type: 'feature',
      description: 'My awesome plugin',
    },
    schemas: [...],    // Database schemas
    routes: [...],     // API routes
    hooks: [...],      // Lifecycle hooks
    services: [...],   // Business logic
    schedules: [...],  // Cron jobs
    onInit: async (ctx) => { /* setup */ },
    onReady: async (ctx) => { /* ready */ },
  });
}

Plugins vs Extensions

Know when to use which approach for your custom logic.

✓ With Baasix

  • Full modules with schemas, routes, services, hooks
  • Publishable to npm, shareable across projects
  • Complete lifecycle management (init, ready, shutdown)
  • Cross-plugin communication built-in
  • Perfect for integrations: payments, auth, AI

✗ Traditional Approach

  • Extensions: simpler, project-specific customizations
  • Limited to hooks, endpoints, scheduled tasks
  • Not easily shareable across projects
  • No schema creation or service registration
  • Best for quick project-specific tweaks

Plugin Types

Feature Plugins

Complete business features like e-commerce, CMS, or blog functionality with schemas, routes, and logic.

Auth Plugins

Authentication providers including OAuth, OTP, Passkey, and custom SSO integrations.

Payment Plugins

Payment processing with Stripe, PayPal, Razorpay, and other payment gateways.

Storage Plugins

File storage providers: S3, Google Cloud Storage, Cloudinary, and custom drivers.

AI Plugins

AI/ML integrations including RAG systems, embeddings, vector search, and LLM providers.

Notification Plugins

Messaging integrations: Email providers, SMS gateways, push notifications.

Full Access to Baasix Services

Plugins receive a rich context with access to all Baasix services.

Your plugin code gets typed access to the database, authentication, file storage, notifications, cache, and all other Baasix services. No manual dependency injection required.

// Plugin route with full service access
const routes = [{
  path: '/my-plugin/process',
  method: 'POST',
  requireAuth: true,
  handler: async (req, res, context) => {
    const { ItemsService, mailService, getCacheService } = context;
    
    // Use ItemsService with user's permissions
    const items = new ItemsService('orders', {
      accountability: req.accountability,
    });
    
    const order = await items.create({ status: 'pending' });
    
    // Send notification
    await mailService.send({
      to: req.user.email,
      template: 'order-confirmation',
      data: { order },
    });
    
    res.json({ success: true, order });
  },
}];

What You Can Build

Plugins enable powerful, reusable functionality across projects.

Payment Integration

Build a Stripe plugin that handles subscriptions, webhooks, invoicing, and customer management. Use across all your SaaS projects.

StripeSubscriptionsPayments

Custom Auth Provider

Create an enterprise SSO plugin for SAML, LDAP, or custom OAuth providers. Share across your organization's projects.

SSOEnterpriseAuthentication

AI-Powered Search

Build a RAG plugin with vector embeddings, semantic search, and LLM integration. Drop into any project needing AI capabilities.

AIRAGVector Search

Multi-Channel Notifications

Create a unified notification plugin supporting email, SMS, push, and in-app channels with templating and delivery tracking.

NotificationsEmailSMS

Plugins FAQ

How are plugins different from extensions?

Extensions are simpler, project-specific customizations (hooks, endpoints, cron). Plugins are full modules that can add schemas, services, routes, and more. Plugins are designed to be reusable and publishable to npm.

Can plugins communicate with each other?

Yes! Plugins can access other plugin services using context.getPluginService(pluginName, serviceName). This enables building plugin ecosystems where plugins can extend each other.

How do I publish a plugin?

Plugins are standard npm packages. Set up your package.json with proper exports, build with tsup or similar, then publish to npm. Users install with npm and register in their server config.

Can plugins add their own database tables?

Absolutely! Plugins can define schemas that create tables, relationships, indexes, and more. These are automatically migrated when the plugin is registered.

Ready to build faster?

Join developers who are shipping production-ready backends in hours, not weeks.