BlueRain OS
  • Introduction
  • API
    • API Reference
  • Guides
    • Apps
      • Installation
      • Creating an App
      • Configuration
    • Components
      • Registering Components
      • Extending Components
      • Replacing Components
      • Accessing Raw Components
      • Components & HoCs
    • Filters
      • Known Filters
    • Plugins
      • Installation
      • Configuration
      • Creating a Plugin
  • Miscellaneous
    • JSON to React
  • Plugins
    • Apollo
    • Internationalization
    • Material UI
    • React Router
    • Redux
    • Redux Devtools
    • Why Did You Update
Powered by GitBook
On this page
  1. Guides
  2. Plugins

Creating a Plugin

All plugins in BlueRain OS extend the Plugin Class.

Let's create a simple plugin that registers a new route /hello-world. When this route is called, HelloWorldComponent component should be rendered.

import { Plugin } from 'bluerain-os';
import HelloWorldComponent from './HelloWorldComponent';

class HelloWorldPlugin extends Plugin {

    static pluginName = HelloWorldPlugin;
    static slug = 'hello-world';
    const hooks = {
        'bluerain.routes':(routes, ctx) => {
            routes.push({
                path: '/hello-world',
                component: HelloWorldComponent
            })
        });
    }
    const uses = {
        hooks:['foo.bar']
    }

    initialize(config, ctx) {
    }
}

export default HelloWorldPlugin;

Notice that we also defined pluginName and slug static properties.

  • pluginName defines the name of the plugin. This is a required property and not providing one will throw error when you register the plugin.

  • slug property defines the slug for your plugin. If you don't give one, then BlueRain will automatically create a slug by kebab casing the pluginName property. It's a good convention manually define the slug. This slug is used to get an app from the PluginRegistry.

  • hooks defines the hooks plugin would add when added to the system.

  • uses defines the hooks plugin is running .

PreviousConfigurationNextJSON to React

Last updated 6 years ago

You can define even more Plugin properties. For a complete list, please refer to the .

API Reference