title: Use community widgets in developer portal titleSuffix: Azure API Management description: Learn about community widgets for the API Management developer portal and how to inject and use them in your code. author: dlepow ms.author: danlep ms.date: 03/25/2021 ms.service: api-management ms.topic: how-to
All developers place their community-contributed widgets in the /community/widgets/
folder of the API Management developer portal GitHub repository. Each has been accepted by the developer portal team. You can use the widgets by injecting them into your self-hosted version of the portal. The managed version of the developer portal doesn't currently support community widgets.
Note
The developer portal team thoroughly inspects contributed widgets and their dependencies. However, the team can’t guarantee it’s safe to load the widgets. Use your own judgment when deciding to use a widget contributed by the community. Refer to our widget contribution guidelines to learn about our preventive measures.
-
Set up a local environment for the latest release of the developer portal.
-
Go to the widget's folder in the
/community/widgets
directory. Read the widget's description in thereadme.md
file. -
Register the widget in the portal's modules:
-
src/apim.design.module.ts
- a module that registers design-time dependencies.import { WidgetNameDesignModule } from "../community/widgets/<widget-name>/widget.design.module"; ... injector.bindModule(new WidgetNameDesignModule());
-
src/apim.publish.module.ts
- a module that registers publish-time dependencies.import { WidgetNamePublishModule } from "../community/widgets/<widget-name>/widget.publish.module"; ... injector.bindModule(new WidgetNamePublishModule());
-
src/apim.runtime.module.ts
- a module that registers run-time dependencies.import { WidgetNameRuntimeModule } from "../community/widgets/<widget-name>/widget.runtime.module"; ... injector.bindModule(new WidgetNameRuntimeModule());
-
-
Check if the widget has an
npm_dependencies
file. -
If so, copy the commands from the file and run them in the repository's top directory.
Doing so will install the widget's dependencies.
-
Run
npm start
.
You can see the widget in the Community category in the widget selector.
:::image type="content" source="media/developer-portal-use-community-widgets/widget-selector.png" alt-text="Screenshot of widget selector":::
Learn more about the developer portal: