Handler hooks
Plugins provide HTTP handlers through the handlers field. Each key identifies the first path
segment after /cms/api/. Each factory receives the final Adapter.
import type { OberonPlugin } from "@oberoncms/core"
export const plugin: OberonPlugin = () => ({
name: "status",
handlers: {
status: () => ({
GET: () => Response.json({ service: "oberon" }),
}),
},
})This example responds to GET /cms/api/status. It reports a service name, not database health.
Dispatch
Factories run once, on the first request with an action segment. Requests reuse the returned
handlers. Supported method keys are GET, POST, PUT, PATCH, and DELETE. Each method
receives a Web Request and returns a Response or Promise<Response>.
A request without an action segment returns 404. A missing handler or unsupported method returns
405. Handler factories run only in the runtime phase.
Next.js route
import { createRestHandler } from "@oberoncms/plugin-nextjs"
import { adapter } from "@/oberon/adapter"
export const { GET, POST, PUT, PATCH, DELETE } = createRestHandler(adapter)TanStack Start route
import { createRestHandler } from "@oberoncms/plugin-tanstack"
import { createFileRoute } from "@tanstack/react-router"
import { adapter } from "../../../../oberon/adapter"
export const Route = createFileRoute("/cms/api/$")({
server: {
handlers: createRestHandler(adapter),
},
})Adjust the Adapter import to match your app layout. The framework integration passes the request
method and route segments to adapter.handleRequest.
Use Adapter hooks to change CMS methods. Use handlers for plugin HTTP endpoints.