NextRush

Plugin Packages

Extend NextRush with controllers, logging, static files, WebSocket, events, and templates.

NextRush plugins extend your application with additional capabilities. Each plugin integrates with the core application through the standardized plugin interface.


Available Plugins

Loading diagram...

Quick Reference

PackagePurposeUse Case
@nextrush/controllersDecorator-based controllersStructured REST APIs
@nextrush/loggerRequest loggingObservability, debugging
@nextrush/staticStatic file servingFrontend assets, downloads
@nextrush/websocketReal-time communicationChat, live updates
@nextrush/eventsEvent emitterDecoupled architecture
@nextrush/templateHTML renderingServer-side pages

Installation

Install plugins as needed:

$ pnpm add @nextrush/controllers @nextrush/logger

Plugin Interface

All NextRush plugins implement a consistent interface:

interface Plugin {
  name: string;
  version?: string;
  install(app: Application): void | Promise<void>;
  destroy?(): void | Promise<void>;
}

Using Plugins

import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { controllersPlugin } from '@nextrush/controllers';
import { eventsPlugin } from '@nextrush/events';

const app = createApp();
const router = createRouter();

// Register plugins
await app.plugin(controllersPlugin({ router, root: './src', prefix: '/api' }));
app.plugin(eventsPlugin());

Plugin Categories

Architecture Plugins

These plugins add structural patterns:

  • Controllers — Class-based route handlers with decorators
  • Events — Decoupled communication between components

Feature Plugins

These plugins add capabilities:

  • Logger — Request/response logging
  • Static — File serving
  • WebSocket — Real-time communication
  • Template — HTML rendering

Combining Plugins

Plugin registration order matters. Middleware plugins (logger, static) should be registered before route-handling plugins (controllers).

Plugins work together:

import { createApp } from '@nextrush/core';
import { createRouter } from '@nextrush/router';
import { controllersPlugin } from '@nextrush/controllers';
import { logger } from '@nextrush/logger';
import { serveStatic } from '@nextrush/static';

const app = createApp();
const router = createRouter();

// Request logging
app.use(logger());

// Static files
app.use(serveStatic({ root: './public' }));

// API controllers
await app.plugin(
  controllersPlugin({
    router,
    root: './src',
    prefix: '/api',
  })
);

Creating Custom Plugins

Build your own plugins:

import type { Plugin } from '@nextrush/types';

const myPlugin: Plugin = {
  name: 'my-plugin',
  version: '1.0.0',

  install(app) {
    // Add middleware
    app.use(async (ctx) => {
      ctx.state.myValue = 'hello';
      await ctx.next();
    });
  },

  destroy() {
    // Cleanup on shutdown
  },
};

app.plugin(myPlugin);

Next Steps

Explore individual plugin documentation:

On this page