303c5ea171
* Refactor route registration * Reference route RFC * Refactor example code to remove deprecated call * Add changeset * Return feature flag
1.0 KiB
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');
},
});