Skip to Content

Plugin shape

A plugin receives the phase and a getter for the final Adapter. It returns its name and optional capabilities:

import type { OberonAdapter, OberonHandler, OberonPluginAdapterHooks, OberonPluginPhase, } from "@oberoncms/core" type Plugin = (context: { getAdapter: () => OberonAdapter; phase: OberonPluginPhase }) => { name: string version?: string disabled?: boolean adapter?: OberonPluginAdapterHooks handlers?: Record<string, (adapter: OberonAdapter) => OberonHandler> bootstrap?: () => Promise<void> }

Use the exported OberonPlugin type for implementations. The example above describes its current contract.

Composition

  • Definitions run in configured order.
  • Disabled plugins contribute metadata only.
  • Later adapter hooks wrap earlier implementations.
  • A hook that does not call next replaces the earlier implementation.
  • Later handler keys replace earlier keys with the same name.
  • Handler factories run once, on the first HTTP request with an action segment.
  • Bootstrap tasks run in configured order.

Do not call getAdapter() while a definition or hook factory runs. It throws until composition is complete. Call it from an executing adapter method or bootstrap task.

Bootstrap example

import type { OberonPlugin } from "@oberoncms/core" export const plugin: OberonPlugin = ({ getAdapter }) => ({ name: "initial-settings", bootstrap: async () => { await getAdapter().putKV({ namespace: "initial-settings", key: "enabled", value: true, }) }, })

Bootstrap callbacks receive no arguments. Capture getAdapter from the plugin context when the task needs the final Adapter. Use Adapter hooks and Handler hooks for other capabilities.

Last updated on