Globals

A global block defines a singleton document — a single instance of a data model, useful for site-wide settings, configuration, or feature flags. Unlike collections (which have many records), globals have exactly one record.

Syntax

global <name> {
  fields: {
    // field definitions
  }
}

The name must be a valid identifier and unique across all .radiant files.

Allowed Properties

Globals support the same allowed properties as collections:

PropertyTypeDescription
fieldsObjectField definitions (same types as collections).
authBooleanNot typically used on globals.
cacheObjectCaching settings.
hooksObjectLifecycle hooks.
adminObjectAdmin UI settings.

Example: Site Settings

global siteSettings {
  fields: {
    siteName: text
    description: textarea
    maintenanceMode: boolean @default(false)
    maxUploadSize: integer @default(10485760)
    theme: select("light", "dark", "auto") @default("auto")
  }
}

Generated Types

Globals produce the same TypeScript types as collections (model, create, update, where clause):

export interface SiteSettings {
  id: string;
  siteName: string;
  description: string;
  maintenanceMode: boolean;
  maxUploadSize: number;
  theme: "light" | "dark" | "auto";
}

export interface SiteSettingsCreate {
  siteName: string;
  description: string;
  maintenanceMode?: boolean;
  maxUploadSize?: number;
  theme?: "light" | "dark" | "auto";
}

export type SiteSettingsUpdate = Partial<SiteSettingsCreate>;

Globals are also registered in the Collections type:

export type Collections = {
  siteSettings: SiteSettings;
  // ...collections...
};

Validation

Globals go through the same field validation as collections:

  • Field types must be in the allowed set
  • Relationship targets must exist
  • select fields must have at least one option
  • Duplicate global names produce an error

Use Cases

  • Site settings — site name, description, maintenance flags
  • Feature flags — toggle features on/off globally
  • Theme configuration — colors, logos, layout
  • Billing plans — current plan, limits, renewal date
  • SEO metadata — default title, description, social image