Skip to main content
Separate from user credentials, services can define admin-level configuration settings. These are configured once by an admin and shared across all users of the service.

Defining settings

const SERVICE_CONFIGURATION_OPTIONS = [
  {
    key: "baseUrl",
    description: "API base URL",
    type: "url",
    required: false,
    defaultValue: "https://api.example.com",
  },
  {
    key: "apiVersion",
    description: "API version to use",
    type: "select",
    required: true,
    defaultValue: "v2",
    options: JSON.stringify([
      { value: "v1", label: "Version 1" },
      { value: "v2", label: "Version 2" },
    ]),
  },
] as const;

Setting fields

FieldRequiredDescription
keyYesUnique identifier for the setting
descriptionYesLabel shown to the admin
typeYesInput type: text, password, url, or select
requiredYesWhether the field is required
defaultValueNoDefault value
optionsNoJSON-stringified array of { value, label } for select type

Accessing settings

Settings are available in the service context:
createClient(context: AuthenticatedServiceContext<Settings, CustomAuth>) {
  const baseUrl = context.serviceConfig.settings.baseUrl;
  return new ApiClient({ baseUrl });
}