Skip to Content

Label SDK

The label SDK allows to add labels to specific anchors, like Assets or Projects. This could also be referred to as tagging. A tagged anchor can be found by searching for the label.

Installation

To install this package, you need to have access to the private @sdk npm scope.

To integrate the SDK Label package into your project, use the following command with your preferred package manager:

npm install @sdk/label

Label Service

A service has to be set up to use the label SDK. The service is responsible for managing the labels and their relations to anchors.

import myConnectClient from './myConnectClient'; import { LabelService, LabelMapper } from '@sdk/label'; const labelService = new LabelService(myConnectClient, new LabelMapper());

The example above shows how to set up a label service. It assumes that myConnectClient is a instance of the Connect client from the @sdk/connect package.

React Integration

In order to have access to the label service in your React components, you can use the LabelServiceProvider:

The LabelServiceProvider has a dependency on the ConnectProvider from the @sdk/connect package.

import { LabelServiceProvider } from '@sdk/label'; export default function App() { return <LabelServiceProvider>{children}</LabelServiceProvider>; }

After wrapping your application with the LabelServiceProvider, you have access to a set of hooks to interact with labels:

  • useLabels: Fetches all labels for a given anchor.
  • useLabelFilter: To search for existing labels that can attached to an anchor.
  • useLabelService: Provides access to the label service and therefore the ability to create, update and delete labels.
Last updated on