@hyperse-hub/hps-plugin-admin
Vendure plugin that serves a dynamic, permission-aware /admin/* UI: HTML shell, injected global data, and Admin API extensions for modules and menus.
Setup
Register the plugin and call init with your host and routes (other fields are optional and merge with built-in defaults):
import { HpsPluginAdmin } from '@hyperse-hub/hps-plugin-admin';
export const config: VendureConfig = {
plugins: [
HpsPluginAdmin.init({
domainUrl: 'https://app.example.com',
}),
],
};
Static defaults live on HpsPluginAdmin.options (including brandName: 'Hyperse'). init() deep-merges your partial options over those defaults.
Configuration (PluginInitOptions)
| Option | Type | Default (after merge) | Description |
|---|
brandName | string | 'Hyperse' | Display name for the admin shell. Injected into every page as window.GLOBAL.brandName. Use useGlobal().brandName from @hyperse-hub/hps-plugin-admin/react in React. |
favicon | string | Buffer | built-in icon | Favicon served under the admin base path. |
domainUrl | string | — | Required in real configs. Public origin without trailing / (e.g. https://shop.example.com). |
defaultRoute | string | /setting | Post-login default route segment (see plugin builtins). |
loginRoute | string | /login | Login page path. |
cookieContentLanguageCodeKey | string | 'languageCode' | Cookie name for UI language. |
cookieChannelTokenKey | string | 'channel' | Cookie name for channel token. |
Global data (AdminPageGlobalData)
The server builds a AdminPageGlobalData object and injects it into the HTML as window.GLOBAL. It combines codegen-shaped fields (administrator, apiBase, domainUrl, elementAclKeys, …) with extra runtime fields: menus, channels, permissions, defaultPage, routeBaseName, and brandName (same value as PluginInitOptions.brandName after init()).
Use this on the client for navigation, permissions, and branding instead of hard-coding product names.
Package exports
| Subpath | Role |
|---|
@hyperse-hub/hps-plugin-admin | Vendure server plugin: HpsPluginAdmin, config types, helpers used in the Node host. |
@hyperse-hub/hps-plugin-admin/react | Client UI library: shared dashboard components, hooks, layouts, and plugin/page registration helpers for React apps that run in (or match) the admin shell. |
Server entry
See src/index.ts for public server-side APIs and types, for example PluginInitOptions, AdminPageGlobalData.
React entry (/react)
Built from dashboard/ into dist/react/ (run yarn build:dashboard or full yarn build). Import as:
import {
useGlobal,
definePlugin,
DataTable,
Providers,
} from '@hyperse-hub/hps-plugin-admin/react';
The bundle treats bare module specifiers (react, @apollo/client, @heroui/react, etc.) as externals, so the host app must install and dedupe compatible versions (match this package’s dependencies where possible).
Rough surface area (see dashboard/index.ts and re-exported barrels):
- Common — e.g. logging helpers under
dashboard/common.
- Hooks —
useGlobal (typed window.GLOBAL / AdminPageGlobalData), useConfirm, useDrawer, routing and layout helpers, etc.
- Components — tables, filters, forms (
HeroForm), asset picker, rich text editor, errors/loading/empty states, i18n wrapper, theme switch, and other shared UI.
- Layouts & providers — shell layouts (
Layout, LayoutMain, …), Providers / LayoutProviders, loading context.
- Extension helpers —
definePage, definePlugin for registering routes and plugins in the admin UI.
- Re-exports —
useQuery, useMutation, useLazyQuery from @apollo/client/react, and useTranslations / useFormatter from use-intl.
Styles: consuming apps that use Tailwind v4 with HeroUI can point content/@source at this package’s dist/react output (similar to ui/theme/globals.css in this repo) so classes used inside these components are generated.
Types for global admin data on the client align with AdminPageGlobalData (also re-exported from /react).