A frontend library that helps other Backstage plugins interact with the catalog through React components, hooks, and utilities.
npx @tessl/cli install tessl/npm-backstage--plugin-catalog-react@1.9.0A frontend library that helps other Backstage plugins interact with the catalog through React components, hooks, and utilities. This package provides a comprehensive set of React components and hooks for building catalog-aware user interfaces within the Backstage platform.
yarn add @backstage/plugin-catalog-reactimport {
EntityTable,
EntityRefLink,
useEntity,
useEntityList,
catalogApiRef,
EntityKindFilter
} from "@backstage/plugin-catalog-react";For alpha features:
import {
createEntityCardExtension,
createEntityContentExtension
} from "@backstage/plugin-catalog-react/alpha";import React from 'react';
import {
useEntityList,
EntityTable,
EntityKindFilter,
EntitySearchBar,
EntityTypeFilter
} from '@backstage/plugin-catalog-react';
import { Entity } from '@backstage/catalog-model';
// Basic entity listing with filtering
function CatalogList() {
const { entities, filters, updateFilters, loading } = useEntityList();
return (
<div>
<EntitySearchBar />
<EntityTable
title="Software Catalog"
entities={entities}
columns={[
{ title: 'Name', field: 'metadata.name' },
{ title: 'Kind', field: 'kind' },
{ title: 'Owner', field: 'spec.owner' }
]}
/>
</div>
);
}
// Using entity context
function EntityDetails() {
const { entity } = useEntity();
return (
<div>
<h2>{entity.metadata.name}</h2>
<p>Owner: {entity.spec?.owner}</p>
</div>
);
}The plugin is organized around several key architectural patterns:
Core React components for displaying and linking to entities in various formats, including tables, links, and display names.
function EntityTable<T extends Entity>(props: EntityTableProps<T>): JSX.Element;
function EntityRefLink(props: EntityRefLinkProps): JSX.Element;
function EntityDisplayName(props: EntityDisplayNameProps): JSX.Element;React hooks for accessing and managing entity data, including current entity context and async loading patterns.
function useEntity<TEntity extends Entity = Entity>(): { entity: TEntity };
function useAsyncEntity<TEntity extends Entity = Entity>(): EntityLoadingStatus<TEntity>;
function useEntityList<EntityFilters extends DefaultEntityFilters = DefaultEntityFilters>(): EntityListContextProps<EntityFilters>;Comprehensive filtering system for entity search and categorization, supporting backend and frontend filtering patterns.
class EntityKindFilter implements EntityFilter {
constructor(value: string);
getCatalogFilters(): Record<string, string | symbol | (string | symbol)[]>;
toQueryValue(): string;
}
class EntityTypeFilter implements EntityFilter {
constructor(value: string | string[]);
getCatalogFilters(): Record<string, string | symbol | (string | symbol)[]>;
toQueryValue(): string | string[];
}Interactive components for selecting and filtering entities by various criteria like kind, type, owner, and tags.
function EntityKindPicker(): JSX.Element;
function EntityTypePicker(): JSX.Element;
function EntityOwnerPicker(): JSX.Element;
function EntityTagPicker(): JSX.Element;API references and utilities for integrating with the Backstage catalog backend and related services.
const catalogApiRef: ApiRef<CatalogApi>;
const starredEntitiesApiRef: ApiRef<StarredEntitiesApi>;
const entityPresentationApiRef: ApiRef<EntityPresentationApi>;Helper functions for entity relationships, source location, ownership checks, and route management.
function getEntityRelations(
entity: Entity | undefined,
relationType: string,
filter?: { kind: string }
): CompoundEntityRef[];
function getEntitySourceLocation(
entity: Entity,
scmIntegrationsApi: ScmIntegrationsApi
): EntitySourceLocation | undefined;
function isOwnerOf(owner: Entity, entity: Entity): boolean;Extension system for creating custom entity cards and content extensions in the new Backstage frontend system.
function createEntityCardExtension<TInputs extends AnyExtensionInputMap>(
options: EntityCardExtensionOptions<TInputs>
): Extension<any>;
function createEntityContentExtension<TInputs extends AnyExtensionInputMap>(
options: EntityContentExtensionOptions<TInputs>
): Extension<any>;interface EntityFilter {
getCatalogFilters?: () => Record<string, string | symbol | (string | symbol)[]>;
filterEntity?: (entity: Entity) => boolean;
toQueryValue?: () => string | string[];
}
type UserListFilterKind = 'owned' | 'starred' | 'all';
interface EntityLoadingStatus<TEntity extends Entity = Entity> {
entity?: TEntity;
loading: boolean;
error?: Error;
refresh?: VoidFunction;
}
interface EntitySourceLocation {
locationTargetUrl: string;
integrationType?: string;
}