On this page
Sommatic Docs
Open portal

Add the Command Center to your app

Mount the Command Center in a React app with three providers, register its commands, and make each page operable with a co-located *.sommatic.jsx file.

View as Markdown
Open in

At the end of this page your app has the Command Center panel, the 37 built-in commands, and pages that tell the Command Center what they show and what can be done on them. Everything comes from @sommatic/react-sdk.

Install

Shell
npm install @sommatic/react-sdk @veripass/react-sdk @link-loom/react-sdk

The SDK expects React 17 to 19 and React Router 5 to 7 in your app. Point its services at your backend once, before the first render, as shown in Configuration.

Mount the providers

The Command Center needs an identity already established, so it goes inside AuthProvider from Veripass. Omnisearch is independent and usually wraps the layout:

JavaScript
import { AuthProvider } from '@veripass/react-sdk';
import { OmniSearchRegistryProvider } from '@link-loom/react-sdk';
import {
  CommandCenterProvider,
  CommandCenterSidebar,
  ConversationExecutionService,
  ConversationManagementService,
  CognitiveInfrastructureLLMProviderService,
  WorkManagementTaskService,
} from '@sommatic/react-sdk';

const executionService = new ConversationExecutionService();
const taskService = new WorkManagementTaskService();

export function App() {
  return (
    <AuthProvider>
      <CommandCenterProvider
        executionService={executionService}
        conversationManagementService={ConversationManagementService}
        llmProviderService={CognitiveInfrastructureLLMProviderService}
        taskService={taskService}
        pageCatalog={pageCatalog}
      >
        <OmniSearchRegistryProvider>
          <Layout />
          <CommandCenterSidebar />
        </OmniSearchRegistryProvider>
      </CommandCenterProvider>
    </AuthProvider>
  );
}

Mount CommandCenterProvider once, near the top of the tree. Mounting it twice resets its registry, and mounting the sidebar without it throws.

PropWhat it is
executionServiceAn instance with execute(envelope) and, optionally, executeStream(envelope, callbacks). ConversationExecutionService calls /chat/conversation/execute and /chat/conversation/execute/stream. With executeStream the panel streams; without it, it falls back to a single request.
conversationManagementServiceThe class that stores conversation history.
llmProviderServiceThe class that lists the LLM providers the person can pick in the panel.
taskServiceOptional. The task service used by the task commands.
currentUserOptional. The signed-in user.
commandsOptional. Command definitions to register from the start.
pageCatalogOptional. [{ path, description }]: the pages /navigate can resolve from a request in natural language.
appCatalogOptional. [{ slug, name, description, tags, default_route }]: the apps /open-app can resolve.

Register the commands

Build the built-in commands with getReadCommands and getExecCommands from a component inside the provider, and register them with registerCommands, which returns a function that unregisters them:

JavaScript
import { useEffect, useMemo } from 'react';
import { useNavigate } from 'react-router-dom';
import { useCommandCenter, getReadCommands, getExecCommands } from '@sommatic/react-sdk';

export function CommandCenterCommands({ icons }) {
  const navigate = useNavigate();
  const { registerCommands, getContext, registry } = useCommandCenter();

  const commands = useMemo(
    () => [...getReadCommands({ getContext, icons, registry }), ...getExecCommands({ navigate, icons, registry })],
    [getContext, navigate, registry, icons],
  );

  useEffect(() => registerCommands(commands), [commands, registerCommands]);

  return null;
}

Open the panel from anywhere

The sidebar listens to DOM events in the sommatic: namespace. To open it from a button or another feature, optionally with a first message:

JavaScript
window.dispatchEvent(
  new CustomEvent('sommatic:open-command-center', {
    detail: { initialMessage: '/page-outline' },
  }),
);

The sidebar broadcasts sommatic:command-center-opened and sommatic:command-center-closed. CommandCenterTrigger is a ready-made button that opens and closes it.

Make a page operable with *.sommatic.jsx

A page tells the Command Center what it shows and what can be done on it through a small wrapper that sits next to it. The wrapper renders nothing; it only registers.

Create the wrapper next to the page

Name it after the page: OrganizationEdit.sommatic.jsx next to OrganizationEdit.jsx. It receives the page’s refs and handlers as props, never its own state, and returns null. Its default export ends in Sommatic.

Publish a context source

useSommaticContextSource publishes a snapshot the model can read. Use the id page-context for the main one: read commands fall back to it when no source is named.

Publish surfaces and targets

useSommaticSurface publishes a region (panel, form, grid, modal, list) with its handlers (submit, cancel, open, close, setFields) and its targets: the inputs, buttons, links and rows inside it, each with handlers such as fill, getValue and click.

Render it from the page

Render the wrapper next to the page’s own markup, passing the refs and handlers it needs.

JavaScript
import { useSommaticContextSource, useSommaticSurface } from '@sommatic/react-sdk';

function OrganizationEditSommatic({ formDataRef, handleSubmit, setIsOpen }) {
  useSommaticContextSource(
    {
      id: 'page-context',
      description: 'Organization edit form.',
      getData: () => ({ ...formDataRef?.current }),
    },
    [],
  );

  useSommaticSurface(
    {
      id: 'organization-edit-form',
      type: 'form',
      label: 'Edit organization',
      handlers: {
        submit: () => {
          handleSubmit?.();
          return { submitted: true };
        },
        cancel: () => {
          setIsOpen?.(false);
          return { cancelled: true };
        },
      },
      targets: [
        {
          id: 'organization-edit-display-name',
          type: 'input',
          label: 'Display name',
          aliases: ['name', 'nombre', 'business name'],
          handlers: {
            getValue: () => formDataRef?.current?.display_name,
            fill: (value) => formDataRef?.current && (formDataRef.current.display_name = value),
          },
        },
      ],
    },
    [],
  );

  return null;
}

export default OrganizationEditSommatic;

A target is addressed as surface_id::target_id, here organization-edit-form::organization-edit-display-name. The Command Center finds it by exact id first and then by label and aliases, so aliases in other languages help people who ask in their own words.

Common problems

  • “No LLM Provider ID provided for inference.” The person has not picked a provider in the panel yet.
  • Surfaces lose their handlers between renders. The provider is mounted twice; keep a single one.
  • Read commands describe the wrong source. Publish a source with the id page-context on every page.

Next steps

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs