Extend the admin UI
Extend the admin with React plugins or add small browser-side changes using the window API.
For the team workflow, see Home.
There are two contracts:
- Plugins, written in React with
@commerce-mind/vox-admin, delivered as an npm package or a browser extension. window.vox, for scripts on the page: the state of the screen, its events and actions, and plain DOM elements in the slots.
The examples on this page add an "Open in ERP" button to products and the margin next to their price, and deliver them both ways.
Write a plugin
A plugin is a plain object:
import { defineVoxPlugin, voxPluginApiVersion, type VoxEntitySlotContext } from '@commerce-mind/vox-admin';
import { Button } from '@commerce-mind/vox-design-system';
function OpenInErp({ entityType, id }: VoxEntitySlotContext) {
return (
<Button outline href={`https://erp.example.com/${entityType.name}/${id}`} target="_blank">
Open in ERP
</Button>
);
}
export const erpPlugin = defineVoxPlugin({
id: 'acme.erp',
apiVersion: voxPluginApiVersion,
slots: {
'entity.header.actions': [
{ id: 'open-in-erp', component: OpenInErp, when: ({ entityType }) => entityType.name === 'Product' },
],
},
});
What a plugin can add:
| Field | What |
|---|---|
slots | components in named places on the screens, see below |
routes | screens inside the shell, eg { path: 'price-rules', element: <PriceRules /> } |
navigation | items of the sidebar in sections and areas, or of a top bar menu, ordered by order |
fieldEditors | editors of fields, by editor hint ([UIHint]), path (Product.texts.name) or type |
valueCells | how values are shown in tables, by type or path |
views | views of lists, by the names [VoxView] uses |
icons | icons by the names [VoxIcon] uses |
providers | components that wrap the whole admin, eg a connection to your own backend |
formStore | where forms keep their values while they're edited, eg a store several people share |
richTextExtensions | Tiptap extensions of rich text fields |
The rules are the same for all of them:
- Order: plugins are added in order, and a contribution replaces one of an earlier plugin with the same key: the
same id in a slot, the same route path, or an editor of the same name. That's how a plugin replaces a built-in
feature, eg the Relations tab is
{ id: 'relations' }inentity.tabs. - Conditions:
when(context)decides where a contribution shows, from the entity type, the entity, the selection of contexts and the user's permissions (can(permission)). - Failures: a contribution that throws is left out, with an error in the console, rather than breaking the screen.
- Versions:
apiVersionis the version of the plugin API the plugin is built for:voxPluginApiVersion, which is 2. It's bumped by a change of the plugin contract that older plugins wouldn't work with, and the admin refuses a plugin of another version, with an error in the console. - A native look: use
@commerce-mind/vox-design-system, whose components and tokens are part of the contract.
The top bar and the sidebar
The shell has a top bar across the window and a sidebar below it. The top bar has the app's name, which opens the
user's default area, the areas when the model has them, each opening its home or its
first page, the search field, what plugins add to shell.topbar, the Administration menu and the account menu at
the user's avatar. On small screens it's one row with the menu button, the app's name, a search button, the rail's
button and the avatar, and the drawer has the areas, the chosen area's home and sections, and the tools that don't
fit.
The search field searches the page's list while the page hands it one, eg "Search products" on the Products list,
with the list's q parameter, and is otherwise a global search that finds entity types and pages by name. A screen of
your own hands its search to the field with usePageSearch({ label, value, onChange }), which returns whether the
shell took it. Only the page's own list does; a list inside another screen, eg a relation tab, keeps its own field.
Ctrl K focuses the field.
The sidebar has the sections of the current area, with the entity types in the sections, placements and order that Vox
resolved, see Navigation: a Link is an item of its section, a More entity type is
behind its section's "N more" toggle, whose open state is kept per user in the browser and which opens by itself on the
page of one of them, and a Hidden one has no item. The entity types under a base marked [VoxNavigation] share the
base's item, which is current on the pages of all of them and leads to the base's page: tiles above one list of their
entities, or a browser of lists for light entity types. A user's pinned entity types are a Pinned section at the top of
every area. The shared entity types and pages, those without an area, are in every area's sidebar, in the area's
section with their title or one of their own. An area of a single page has no sidebar and no shared items, and its
page takes the whole width.
The current area is the area of the page's item, eg Catalog on a product's page, or the area of the home the user is
on. Any other page, eg a shared entity type's list, a page without an item or an administration page, keeps the area
the user was in, which the shell puts in the URL's area parameter, eg /markets?area=content, replacing the entry in
the history. A link doesn't need to carry it, and a copied URL opens in the same area. area is reserved, so a list
never reads it as a filter. useVoxAreas() gives a screen the areas the user sees, in order, and the current one.
Tool areas
A tool area is an area of its own that's opened from an item on the right of the top bar, before the Administration
menu, rather than from the areas on the left, eg the built-in Studio. Every page under its home is in it: the
item is current there, the shell shows the tool area's own sidebar component instead of the navigation, and the page
is in none of the other areas, so it gets no shared items, pins or area parameter. A tool area also works in an
application with one unnamed area, without that area's items appearing in it. On small screens its item is in the
drawer, which shows its sidebar while one of its pages is open. Its routes are ordinary routes.
defineVoxPlugin({
id: 'acme.workshop',
apiVersion: 2,
toolAreas: [
{
id: 'workshop',
label: 'Workshop',
icon: 'beaker',
home: '/workshop',
// Renders the sections of the sidebar, eg with SidebarSection and SidebarItem of the design system
sidebar: WorkshopSidebar,
when: ({ can }) => can('acme:Workshop'),
},
],
routes: [{ path: 'workshop', Component: WorkshopHome }],
});
A later plugin's tool area with the same id replaces an earlier one's. badge adds a short text after the label, eg a
count. The sidebar component renders every item of the tool area itself: a navigation item whose area is a tool
area's id isn't shown anywhere.
Homes
An area can have a home, eg /areas/catalog for Catalog (toAreaSlug makes the name a part of a URL). There's none
by default: an area without a home opens the first page of its menu, eg Products, and so does its /areas/{slug}. /
opens the user's default area, the first area they see. A route with home gives an area a home of its own, and a
route with index: true is the home of every other area and of an app without areas, at /. The built-in
HomeScreen shows the area's name and a welcome, with the rail's home sections beside it; add it with
{ index: true, Component: HomeScreen }.
defineVoxPlugin({
id: 'acme.catalog-home',
apiVersion: 2,
routes: [{ home: 'Catalog', Component: CatalogHome }],
});
A later plugin's home of an area replaces an earlier one's. An area with a home of its own is never an area of a single
page. A home's layout is shell or wide.
A plugin's navigation items are added to the sections with their titles in their area, or to new ones, ordered by
order, and VoxShell's navigation prop changes the whole navigation. An item with menu: 'administration' is in
the Administration menu instead, under its section as a heading, eg the built-in Subscriptions under Integrations,
and one with menu: 'account' is in the account menu, eg My navigation. The users, roles and API clients are always in
the Administration menu, under Access. An item links to a page of the admin with href, or runs onSelect instead, eg
to open another app in a new tab, as Jobs and queues opens the Nexus admin. buildEntityNavigation,
groupAreas, isEntityTypeInArea, getNavigationTrail, Breadcrumbs, useEntityTypeCrumbs, EntityTiles, PinButton and usePins are
exported for screens of your own, eg breadcrumbs that say where an entity type is reached through, like Content /
Blocks / Homepage hiking hero.
Slots
Each slot gives its contributions a context as props: every slot has the user, list slots the entity type and the
state of the list, and entity slots the entity type, id, entity, selection of contexts (contextSelection), edit target and selected entities.
| Slot | Where |
|---|---|
shell.providers | wraps the shell, inside the router |
shell.topbar | compact items in the top bar, also in the drawer of small screens (~300px) |
shell.navigation | the bottom of the sidebar, the area footer; its context has the area |
shell.banner | banners above the content of every screen, with ShellBanner |
shell.user-menu | items of the account menu, at the user's avatar |
shell.rail, list.rail, entity.rail | sections of the rail at the right of every screen, a list and an entity |
list.toolbar, list.row.actions, list.empty | above a list, in each row of a table, below an empty list |
list.filters | filters after the filters of a list's fields, with ListFilterChip |
list.selection.actions | actions on the selected entities of a list, eg Export Excel |
entity.header.actions | the buttons in the header of an entity |
entity.draft-bar | below the draft bar |
entity.tabs | tabs of an entity, with a label and a badge |
entity.form.before, entity.form.after | above and below the sections |
entity.section.header | the header of a section, before its language picker |
entity.field.adornment, entity.field.decorator | next to a field's label, and around its editor or value |
richtext.toolbar | buttons in the toolbar of a rich text field |
list.screen, entity.screen | replace the whole screen of an entity type or an entity |
entity.form.before and entity.form.after show on whichever field tab is
open. A tab in entity.tabs with the same id as a field tab of the entity type can't be opened there, since the field
tab comes first, and the admin says so in the browser console.
Plugins get the entity type whole, whatever perspective someone looks
from. Entity slots have the current one as perspective, null for All fields, and anywhere else usePerspective() from
@commerce-mind/vox-client returns it. A plugin that wants to hide what the perspective hides can check a field with
isFieldShown(field, perspective) and an entity type with isEntityTypeShown(entityType, perspective).
A contribution that saves the entity another way than the form, eg a button in entity.header.actions that runs an
action, waits while the slot context's hasUnsavedChanges is set: its save changes the entity's version, which starts
the form again from the saved entity and would throw away what the editor typed.
The rail
The rail is a column at the right of the content, with sections about what's on the screen: on the canvas beside the content from 1600px, a strip of the sections' icons below that, which open one at a time over the content's edge, and a button in the top bar that opens them as a drawer on small screens. The user collapses and expands the rail and its sections, hides them and changes their order, which is kept on the server for them, so that it's the same on every device.
A section has a title, an icon and a body, and optionally a badge after its title and a count of what needs attention, which shows on its icon in the strip:
const erpPlugin = defineVoxPlugin({
id: 'acme.erp',
apiVersion: voxPluginApiVersion,
slots: {
'entity.rail': [
{
id: 'erp',
title: 'ERP',
icon: 'currency-dollar',
order: 200,
when: ({ entityType }) => entityType.name === 'Product',
badge: ({ entity }) => `${entity.margin}%`,
component: ({ entity, compact }) => <ErpFigures sku={entity.id} compact={compact} />,
},
],
},
});
The sections of entity.rail show on the screen of an entity, those of list.rail on a list, and those of
shell.rail on every screen, after the screen's own. A section gets the context of its slot, and compact when it's
shown compactly. The context of the shell's slots has the current area and isHome, so a section shows on one
area's home only with when: ({ isHome, area }) => isHome && area === 'Catalog'. The built-in sections of an entity are assessments, file, used-in, activity, contexts,
relations, releases and versions, of a list needs-attention, overview and saved-filters, and of the homes,
in shell.rail, drafts and assessment-health, which show the area's own and shared entity types, and
open-releases and subscription-health. A plugin replaces
one with the same id. The assessments' sections come from the built-in voxAssessmentsPlugin, see
Entity assessments.
Clicking an entity in a list selects it, and its title, or Enter, opens it. The selection is in the URL, eg
?selected=1042, and the arrow keys move it. The rail then shows the entity, with Open and Publish, and the sections
of entity.rail with compact set, so a plugin adds its sections of an entity once. The list's slots get the
selection as list.selected, and change it with list.select(id). A view that a plugin adds gets onSelect, which is
unset where there's no rail beside the list, eg on small screens, where clicking an entity opens it.
A relation shown as a tab of its own, see Layouts, lists the related
entities on the screen of an entity, with the rail of a list. The list's slots get the relation's filter in
list.filters, eg { "relation.categories": ["jackets"] }, and on its own in scope, since it isn't in the URL.
<EntityListScreen entityType={products} scope={scope} embedded /> shows such a list on a plugin's screen.
A screen that replaces a built-in one in list.screen or entity.screen renders the rail with
<VoxRail slot="entity.rail" context={context} title="For this campaign" />. useVoxShell().openRailSection(id)
shows a section, eg when the user clicks a count that it explains.
Fields and forms
The field slots reach every field the admin shows: editable and read-only, nested in objects and lists, each language
of a varying value, rich text, and the fields of the create screen and of actions' dialogs. Their context has the
field's path in the form, eg texts.name.sv or variants[2].sku, its value, whether it's editable and the form's
store, so a plugin can anchor something to exactly that value.
A field with an editor from fieldEditors, by its hint or its path, gets a row of its own on the entity screen, since
the admin can't know how much room the editor needs; see
how much room a field gets. The built-in multiline,
textarea and selection editors keep their known sizes. An editor gets the props VoxFieldEditorProps, including
fallback: the text, or the document for rich text, that readers get while an empty context's value is empty, eg the
English name of an empty Danish one. A rich text editor gets and sets its value as the rich-text document too, see
VoxRichTextDocument in the client, and admin-core's richTextToHtml, htmlToRichText and RichTextView convert
and show it. An editor that can show it, shows it greyed out in place of its prompt, as the built-in
text and rich text editors do; an editor that ignores it loses nothing, since a note below the field says where the value
comes from.
A form keeps its values in a VoxFormStore: read and subscribe by path, set a value, the original values, what
changed, reset, and the events change and saved. A plugin's formStore replaces the admin's own store for the
forms its when allows, eg with a store that several people edit together. Saving is the same whichever store keeps
the values: the changes become one batch of actions.
Deliver a plugin as an npm package
Build the plugin as an ES module, with @commerce-mind/vox-admin, @commerce-mind/vox-client,
@commerce-mind/vox-design-system and React as peer dependencies, and add it to the admin after the built-in plugins:
const admin = createVoxAdmin({ vox, plugins: [...defaultPlugins, erpPlugin] });
This works in an admin you build yourself with createVoxAdmin. The admin that Vox.UI serves doesn't load npm packages
yet: add-ons that bring their frontend in their .NET assembly come later.
window.vox
Scripts on the page of the admin get window.vox. It's set when the admin starts, which fires vox:ready on
window, and it gives the same state and actions as plugins get from useVoxAdmin().page. It never exposes access
tokens: requests go through Vox's client.
window.vox.apiVersion; // 1
window.vox.state; // { pathname, search, entityType, entityId, entity, contextSelection, selection, form, user }
const stop = window.vox.on('entity:loaded', ({ entityType, id, entity }) => {});
stop();
window.vox.navigate('/products');
window.vox.openEntity('Product', '1042');
await window.vox.refresh();
await window.vox.runAction('ScheduleCampaign', { startsAtUtc: '2026-11-01T00:00:00Z' });
window.vox.form.setValue('texts.name.sv', 'Regnjacka');
await window.vox.form.save();
window.vox.toast('Synced with the ERP');
window.vox.openRailSection('comments');
- Events:
navigated,entity:loaded,entity:saved,selection:changedandform:changed. - Actions work where the admin can do them, eg saving where there's a form, and fail elsewhere: those that return
promises reject.
form.save()rejects if a value isn't valid, and the errors show on the screen.
DOM elements in slots
A script that doesn't use React adds plain DOM to the slots of the shell, lists and entities, and next to fields' labels:
window.vox.slots.mount('entity.header.actions', (element, context) => {
const button = document.createElement('button');
button.textContent = 'Open in ERP';
button.onclick = () => window.open(`https://erp.example.com/items/${context.id}`);
element.append(button);
return () => button.remove();
});
A section of the rail takes a title and an icon:
window.vox.slots.mount('entity.rail', (element, context) => element.append(renderStock(context.id)), {
id: 'stock',
title: 'Stock',
icon: 'archive-box',
});
The admin renders an empty element for each, with data-vox-slot, data-vox-entity-type, data-vox-entity-id and,
for fields, data-vox-field-path, and never changes what's inside it. It mounts again in a new element when the
entity or field changes, and empties the element when it unmounts. mount returns a function that removes it.
Deliver a plugin as a browser extension
A browser extension can contain a full plugin, while experimenting or for a customer's own tweaks. It can do anything an npm plugin can, including replacing built-in screens, adding providers and replacing the form store.
The plugin must use the admin's own React and Vox packages, since its hooks read the admin's React context.
window.vox.modules has them: react, react/jsx-runtime, react-dom, @commerce-mind/vox-admin,
@commerce-mind/vox-client, @commerce-mind/vox-design-system, react-router and @tanstack/react-query.
Build it with the Vite preset
Write the plugin with normal imports, export it as the default export of an entry, and build it with
voxBrowserExtension. It maps the shared packages to window.vox.modules and wraps the script so that it registers
the plugin when the admin starts:
// vite.extension.config.ts
import { voxBrowserExtension } from '@commerce-mind/vox-admin/vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
export default defineConfig({
plugins: [react(), voxBrowserExtension({ entry: 'src/extension.ts' })],
build: { outDir: 'extension', emptyOutDir: false },
});
This builds extension/vox-plugin.js. The code of the plugin runs when the admin fires vox:init, so code at the top
of its modules can use the shared packages too.
Run it in the main world
A content script normally runs in an isolated world, which can't see the page's window. Run it in the page's main
world, and at document_start, so that it's there before the admin starts:
{
"manifest_version": 3,
"name": "Vox ERP example",
"version": "0.0.1",
"content_scripts": [
{
"matches": ["https://vox.example.com/*"],
"js": ["vox-plugin.js"],
"run_at": "document_start",
"world": "MAIN"
}
]
}
Put the manifest in the extension folder next to the built vox-plugin.js, with matches set to your admin's address.
To try it, open chrome://extensions, turn on Developer mode, choose Load unpacked and pick the extension folder.
Without build tools
A script can register a plugin itself, in either of two ways. Both are synchronous, so the admin never waits:
// Before the admin starts
(window.voxPlugins ??= []).push(plugin);
// While the admin starts, with the shared modules
window.addEventListener('vox:init', ({ detail }) => {
const { createElement: h } = window.vox.modules['react'];
const { Button } = window.vox.modules['@commerce-mind/vox-design-system'];
detail.register(
window.vox.definePlugin({
id: 'acme.erp-link',
apiVersion: 2,
slots: {
'entity.header.actions': [
{
id: 'open-in-erp',
component: ({ id }) => h(Button, { outline: true, href: `https://erp.example.com/items/${id}` }, 'Open in ERP'),
},
],
},
}),
);
});
A plugin that arrives after the admin started is refused, with a warning in the console.
Turn it off
window.vox, its modules and the plugins of scripts on the page are on by default. Turn them all off with
ExposeWindowApi:
builder.AddVox(...)
.AddAdminUI(options => options.ExposeWindowApi = false);
An admin you build takes createVoxAdmin({ exposeWindowApi: false }). Code in the page's main world can do anything on
the page anyway, so there's no separate setting for plugins from extensions.