@ungic/admin
v0.7.0
Published
The ungic admin panel, prebuilt: a standalone SPA (dist/app) that boots from the core's GET /api/admin/bootstrap, plus serveAdmin(app) to mount it on a Hono app in one line.
Readme
@ungic/admin
The ungic admin panel, prebuilt: a single-page app that boots at runtime from the CMS's GET /api/admin/bootstrap
(schema, admin config, branding, staff permissions), plus serveAdmin(app) to mount it on a Hono app.
import { serveAdmin } from '@ungic/admin';
serveAdmin(app); // /admin/ → the panel
serveAdmin(app, { base: '/cp' }); // anywhere elseThe ungic CLI mounts it for you (ungic dev, ungic start). Custom admin pages and field editors are React
components in the Site's admin/ folder, registered in ungic.config.ts (admin.customPages, admin.customFields)
and compiled and served by the CLI; type a field editor with import type { FieldEditorProps } from '@ungic/admin'.
They can use the panel's own components, so they look like the rest of the admin:
// admin/tracking-field.tsx
import type { FieldEditorProps } from '@ungic/admin';
import { Button, Input } from '@ungic/admin/components';
export default function TrackingField({ id, value, onChange, disabled }: FieldEditorProps) {
return (
<span style={{ display: 'flex', gap: 8 }}>
<Input id={id} value={typeof value === 'string' ? value : ''} disabled={disabled} onChange={(e) => onChange(e.target.value)} />
<Button size="sm" disabled={disabled} onClick={() => onChange(`TRK-${Date.now().toString(36)}`)}>New code</Button>
</span>
);
}@ungic/admin/components exports PageHeader, Button, Input, Textarea, Field, Select, Switch, Checkbox,
Menu, Notice, Badge, EmptyState and useAdmin() (the panel's locale, direction, read-only state and
permissions). The package carries their types (they need @types/react); the code is the running panel's: the CLI
leaves the import as it is and the admin page's import map resolves it, so nothing of the panel is bundled into your
module. Imported anywhere but inside the admin, it throws.
Documentation
- Admin: staff and roles, the panel's pages, custom pages and field editors (a working example).
- Ungic CMS documentation.
License: Apache-2.0.
