Skip to main content
The plugin ships two UI renderers: scalar() and swaggerUi(). Each is a separate Payload plugin you add alongside openapi() — mount one, or both on different paths:
payload.config.ts
Each renderer serves a single HTML page that loads the UI library from a CDN and points it at the spec endpoint. Paths are relative to the Payload API route (routes.api, /api by default).

Options

Both renderers accept the same options: The default cdnBase is https://cdn.jsdelivr.net/npm/@scalar/api-reference for Scalar and https://cdn.jsdelivr.net/npm/swagger-ui-dist for Swagger UI.

Passing UI configuration

configuration is passed straight through to the underlying library — Scalar’s createApiReference config or Swagger UI’s SwaggerUIBundle options. It must be JSON-serializable; functions aren’t supported here.
payload.config.ts

Serving a static spec

The UI loads the spec from a URL, and that URL doesn’t have to be the plugin’s runtime endpoint. Point specEndpoint at a pre-generated file and the UI renders it directly:
payload.config.ts
See Static spec for generating the file with the CLI.

Language switcher

For multi-language docs, point Scalar’s sources at the spec endpoint with different ?lang= values. When sources is set, the renderer’s own specEndpoint is ignored. Swagger UI has no built-in switcher — mount one instance per language instead. See Internationalization for both setups.