function
defineAdmin
Configure the custom components, installed plugins, and translations used by your application’s admin.
Example
import { defineAdmin } from '@riducms/plugin/admin';
import { generatedAdminPlugins } from './ridu.plugins.generated';
import WelcomePanel from './components/welcome-panel.svelte';
export default defineAdmin({
plugins: generatedAdminPlugins,
dashboard: [
{ key: 'welcome', component: WelcomePanel, position: 'before' }
]
});Arguments
| Argument | Description |
|---|---|
config | Required configuration object. Every property inside it is optional; choose the parts of the admin you want to customize below. |
Admin options
| Property | Type | Description |
|---|---|---|
plugins | readonly AdminPlugin[] | Optional. Installed admin packages. Keep generatedAdminPlugins here so plugins installed through the CLI, such as rich text, are loaded. |
fields | Readonly< | Optional. Custom inputs made with defineFieldEditor. Register under app:name, then select that name in the Go field’s Admin.Editor setting. |
rowLabels | Readonly< | Optional. Array and block headings made with defineRowLabel. Select their app:name keys through Admin.RowLabel in Go. |
messages | PluginMessageCatalog | Optional. Application interface messages made with defineAdminMessages; use app:messageName to translate them. |
languages | readonly TranslationLanguage[] | Optional. Bundled translations for the admin interface. These are separate from the locales used for document content. |
routes | readonly AdminRoute[] | Optional. Add pages inside the admin, each with a relative path, component, and optional navigation link. Plugin routes must also appear in the Go descriptor. |
dashboard | readonly AdminDashboardPanel[] | Optional. Add panels before or after the dashboard, or replace it. Each entry names a key, component, and position; the default position is after. |
listCells | readonly AdminListCell[] | Optional. Change how a field appears in a collection table. Each entry selects a collection, field path, and component. |
documentViews | readonly AdminDocumentView[] | Optional. Add tabs beside Edit and API on saved documents or globals. Each entry includes a key, label, and component; collection can limit where it appears. |
documentActions | readonly AdminDocumentAction[] | Optional. Add buttons to saved collection documents. A component implements the action; an optional requires permission hides it when the user lacks that permission. |
views | readonly AdminCoreView[] | Optional. Wrap or replace collection lists, create/edit forms, global editors, or the not-found page. The component can render defaultView to keep the built-in screen. |
branding | readonly AdminBrandComponent[] | Optional. Replace the login logo, navigation logo, or account avatar. Each location accepts one replacement. |
navigation | readonly AdminNavigationComponent[] | Optional. Add content around the navigation links or replace navigation. Use routes for a new page with its own navigation link. |
login | readonly AdminLoginComponent[] | Optional. Add content before or after sign-in, or replace the screen. A replacement can render defaultView to retain the login form. |
account | readonly AdminAccountComponent[] | Optional. Add content to or replace the profile or security screen, selected by surface. |
logoutButton | AdminLogoutButton | Optional. Replace the account menu’s sign-out control. The component receives host.logout() to end the session. |
shell | readonly AdminShellComponent[] | Optional. Add a component to the header, global actions, or account settings menu. |
providers | readonly AdminProvider[] | Optional. Share context between components by wrapping the admin. The first provider is outermost; every provider must render defaultView. |
Returns
The same AdminConfig object after checking its registrations. Export it as the default from admin/src/admin.config.ts; calling defineAdmin does not render components or send requests.
AdminConfigHow it works
Use this function once in admin/src/admin.config.ts. Keep plugins: generatedAdminPlugins when adding your own settings so installed plugins continue to load.
The fields map contains application inputs made with defineFieldEditor. It is different from defineAdminPlugin’s fields map, which contains editors for new Go plugin field types.
Installed plugins are processed first, followed by application entries. Keys must be unique, and conflicting replacements cause an error rather than silently replacing one another.
The helper checks JavaScript registrations immediately. Run ridu check to also compare them with the Go schema, including component selections, supported field types, routes, and settings.
The example adds WelcomePanel above the dashboard. The Custom components tutorial includes the Svelte component and shows how to try it.
Full signature
function defineAdmin(config: AdminConfig): AdminConfigRelated types
AdminConfigSettings exported from admin/src/admin.config.ts to customize one application’s admin.
AdminPluginA Go plugin’s exported collection of admin field editors, pages, and other components.
RegisteredFieldEditorRegistration returned by
defineFieldEditor; store it indefineAdmin({ fields: ... }).RegisteredRowLabelHelper result stored in
defineAdmin({ rowLabels: ... }); do not construct it manually.PluginMessageCatalogA validated plugin-owned fallback catalog and its language catalogs.
AdminRouteA plugin route mounted beneath the authenticated admin layout.
AdminDashboardPanelA component composed around or replacing the framework dashboard overview.
AdminListCellA renderer for one exact collection and field pair.
AdminDocumentViewA read-only or operational view rendered beside Edit and API.
AdminDocumentActionAn action rendered beside framework document actions.
AdminCoreViewA replacement or wrapper for collection, global, or not-found routes.
AdminBrandComponentA replacement graphic at an exact branding surface.
AdminNavigationComponentA component inserted into or replacing framework navigation.
AdminLoginComponentA component composed around or replacing sign-in.
AdminAccountComponentA component composed around or replacing profile or security.
AdminLogoutButtonThe single optional replacement for the account-menu sign-out control.
AdminShellComponentA component inserted at a global shell position.
AdminProviderA Svelte context provider wrapping the remaining provider stack and admin.