Files
backstage/docs/reference/createPlugin.md
T
Adam Harvey 303c5ea171 chore(sentry,welcome): Refactor route registration to remove deprecating code (#3493)
* Refactor route registration

* Reference route RFC

* Refactor example code to remove deprecated call

* Add changeset

* Return feature flag
2020-11-30 09:04:13 +01:00

1.0 KiB

id, title, description
id title description
createPlugin createPlugin Documentation on createPlugin

Takes a plugin config as an argument and returns a new plugin.

Plugin Config

function createPlugin(config: PluginConfig): BackstagePlugin;

type PluginConfig = {
  id: string;
  register?(hooks: PluginHooks): void;
};

type PluginHooks = {
  router: RouterHooks;
};

Example Uses

Creating a basic plugin

Showcasing adding a route and a feature flag.

import { createPlugin, createRouteRef } from '@backstage/core';
import ExampleComponent from './components/ExampleComponent';

export const rootRouteRef = createRouteRef({
  path: '/new-plugin',
  title: 'New Plugin',
});

export default createPlugin({
  id: 'new-plugin',
  register({ router, featureFlags }) {
    router.addRoute(rootRouteRef, ExampleComponent);
    featureFlags.register('enable-example-component');
  },
});