|
| 1 | +--- |
| 2 | +title: Backstage |
| 3 | +sidebar_position: 50 |
| 4 | +description: 'Integrate Flagsmith feature flags into your Backstage developer portal' |
| 5 | +--- |
| 6 | + |
| 7 | +The [Flagsmith Backstage Plugin](https://github.com/Flagsmith/flagsmith-backstage-plugin) brings feature flag management |
| 8 | +directly into your [Backstage](https://backstage.io/) developer portal. It provides three components: |
| 9 | + |
| 10 | +- **Feature Flags Tab** — A full flag list with environment states, tags, and toggle status. |
| 11 | +- **Overview Card** — A quick summary of your feature flags for entity overview pages. |
| 12 | +- **Usage Card** — A chart showing flag usage metrics over time. |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +## Prerequisites |
| 17 | + |
| 18 | +- A running [Backstage](https://backstage.io/) instance. |
| 19 | +- A Flagsmith account with an **Admin API Key**. |
| 20 | +- Your Flagsmith **Project ID** and **Organisation ID**. |
| 21 | + |
| 22 | +## Installation |
| 23 | + |
| 24 | +Install the plugin from your Backstage app root: |
| 25 | + |
| 26 | +```bash |
| 27 | +yarn --cwd packages/app add @flagsmith/backstage-plugin |
| 28 | +``` |
| 29 | + |
| 30 | +## Configuration |
| 31 | + |
| 32 | +Add the Flagsmith proxy configuration to your `app-config.yaml`: |
| 33 | + |
| 34 | +```yaml |
| 35 | +proxy: |
| 36 | + endpoints: |
| 37 | + '/flagsmith': |
| 38 | + target: 'https://api.flagsmith.com/api/v1' |
| 39 | + headers: |
| 40 | + Authorization: Api-Key ${FLAGSMITH_API_TOKEN} |
| 41 | +``` |
| 42 | +
|
| 43 | +:::tip |
| 44 | +
|
| 45 | +If you are self-hosting Flagsmith, replace the `target` URL with your own Flagsmith API address, e.g. |
| 46 | +`https://flagsmith.example.com/api/v1`. |
| 47 | + |
| 48 | +::: |
| 49 | + |
| 50 | +## Adding Components to Entity Pages |
| 51 | + |
| 52 | +Edit your `packages/app/src/components/catalog/EntityPage.tsx` to add the Flagsmith components. |
| 53 | + |
| 54 | +### Feature Flags Tab |
| 55 | + |
| 56 | +Import and add the `FlagsTab` as a new tab on your entity page: |
| 57 | + |
| 58 | +```tsx |
| 59 | +import { FlagsTab } from '@flagsmith/backstage-plugin'; |
| 60 | +
|
| 61 | +// Inside your entity page layout, add a new tab: |
| 62 | +<EntityLayout.Route path="/feature-flags" title="Feature Flags"> |
| 63 | + <FlagsTab /> |
| 64 | +</EntityLayout.Route> |
| 65 | +``` |
| 66 | + |
| 67 | + |
| 68 | + |
| 69 | +### Overview Card |
| 70 | + |
| 71 | +Add the `FlagsmithOverviewCard` to your entity overview page: |
| 72 | + |
| 73 | +```tsx |
| 74 | +import { FlagsmithOverviewCard } from '@flagsmith/backstage-plugin'; |
| 75 | +
|
| 76 | +// Inside your overview grid: |
| 77 | +<Grid item md={6}> |
| 78 | + <FlagsmithOverviewCard /> |
| 79 | +</Grid> |
| 80 | +``` |
| 81 | + |
| 82 | +<img src="/img/integrations/backstage/overview-card.png" alt="Overview Card" width="600" /> |
| 83 | + |
| 84 | +### Usage Card |
| 85 | + |
| 86 | +Add the `FlagsmithUsageCard` to display flag usage metrics: |
| 87 | + |
| 88 | +```tsx |
| 89 | +import { FlagsmithUsageCard } from '@flagsmith/backstage-plugin'; |
| 90 | +
|
| 91 | +// Inside your overview grid: |
| 92 | +<Grid item md={6}> |
| 93 | + <FlagsmithUsageCard /> |
| 94 | +</Grid> |
| 95 | +``` |
| 96 | + |
| 97 | +<img src="/img/integrations/backstage/usage-card.png" alt="Usage Card" width="600" /> |
| 98 | + |
| 99 | +## Entity Annotations |
| 100 | + |
| 101 | +Annotate your entities in `catalog-info.yaml` so the plugin knows which Flagsmith project to display: |
| 102 | + |
| 103 | +```yaml |
| 104 | +apiVersion: backstage.io/v1alpha1 |
| 105 | +kind: Component |
| 106 | +metadata: |
| 107 | + name: my-service |
| 108 | + annotations: |
| 109 | + flagsmith.com/project-id: '<YOUR_PROJECT_ID>' |
| 110 | + flagsmith.com/org-id: '<YOUR_ORG_ID>' |
| 111 | +spec: |
| 112 | + type: service |
| 113 | + owner: my-team |
| 114 | + lifecycle: production |
| 115 | +``` |
| 116 | + |
| 117 | +| Annotation | Required | Description | |
| 118 | +| -------------------------- | -------- | ------------------------------------------------------------------ | |
| 119 | +| `flagsmith.com/project-id` | Yes | The numeric ID of your Flagsmith project. | |
| 120 | +| `flagsmith.com/org-id` | Yes | The numeric ID of your Flagsmith organisation. | |
| 121 | + |
| 122 | +## Getting Your Credentials |
| 123 | + |
| 124 | +### Admin API Key |
| 125 | + |
| 126 | +1. Log in to [Flagsmith](https://app.flagsmith.com/). |
| 127 | +2. Navigate to **Account Settings > Keys**. |
| 128 | +3. Copy your **Admin API Key**. |
| 129 | + |
| 130 | +### Project ID |
| 131 | + |
| 132 | +1. Open your Flagsmith project. |
| 133 | +2. Go to **Project Settings**. |
| 134 | +3. The **Project ID** is displayed at the top of the settings page. |
| 135 | + |
| 136 | +### Organisation ID |
| 137 | + |
| 138 | +1. Navigate to **Organisation Settings**. |
| 139 | +2. The **Organisation ID** is displayed at the top of the settings page. |
0 commit comments