If you have an existing backend that is not yet using the new backend system, see migrating.
This section covers how to set up and customize your own Backstage backend. It covers some aspects of how backend instances fit into the larger system, but for a more in-depth explanation of the role of backends in the backend system, see the architecture section.
Overview
A minimal Backstage backend is very lightweight. It is a single package with a package.json
file and a src/index.ts
file, not counting surrounding tooling and documentation. The package is typically placed within the packages/backend
folder of a Backstage monorepo, but that is up to you. The backend package is part of any project created with @backstage/create-app
, so you typically do not need to create it yourself.
When you create a new project with @backstage/create-app
, you'll get a backend package with a src/index.ts
that looks something like this:
import { createBackend } from '@backstage/backend-defaults'; // Omitted in the examples below
const backend = createBackend();
backend.add(import('@backstage/plugin-app-backend'));
backend.add(import('@backstage/plugin-catalog-backend'));
backend.add(import('@backstage/plugin-scaffolder-backend'));
backend.add(
import('@backstage/plugin-catalog-backend-module-scaffolder-entity-model'),
);
backend.start();
There will be a couple more plugins and modules in the initial setup, but the overall layout is the same.
What we're doing in this file is creating a new backend using createBackend
, and then installing a collection of different plugins, modules, and services that we want to be part of that backend. Plugins are standalone features, modules augment existing plugins or modules, while services can be used to override behavior for deeper customizations. Each module can only target a single plugin, and that plugin must also be present in the same backend. Finally, we start up the backend by calling the start
method.