Skip to main content
The getWorkspaceSetting() function retrieves a single workspace setting value by key.
// In client code (React components, actions, etc.)
import {getWorkspaceSetting} from "attio/client"

// In server functions
import {getWorkspaceSetting} from "attio/server"
For React components, consider using useWorkspaceSettings() instead, which provides real-time updates when settings change.

Parameters

key
string
required
The key of the setting to retrieve. Must match a key defined in your workspace settings schema.The key is fully typed, so TypeScript will only allow valid setting keys.

Returns

A promise that resolves to the value of the requested setting. The return type is automatically inferred based on the setting type in your schema.

Example

check-sync-status.server.ts
import {getWorkspaceSetting} from "attio/server"

export default async function checkSyncStatus() {
  // Get a single setting value
  const autoSyncEnabled = await getWorkspaceSetting("auto_sync_enabled")

  // TypeScript knows this is a boolean
  if (autoSyncEnabled) {
    const syncInterval = await getWorkspaceSetting("sync_interval_minutes")

    // TypeScript knows this is a number
    return {
      status: "enabled",
      interval: syncInterval,
    }
  }

  return {status: "disabled"}
}

In Client Code

widget.tsx
import {getWorkspaceSetting, Widget} from "attio/client"
import type {App} from "attio"

export const syncWidget: App.Record.Widget = {
  id: "sync-status",
  label: "Sync Status",
  Widget: async ({recordId}) => {
    // Get a single setting
    const autoSyncEnabled = await getWorkspaceSetting("auto_sync_enabled")

    return (
      <Widget.TextWidget>
        <Widget.Title>Auto-sync</Widget.Title>
        <Widget.Text.Primary>{autoSyncEnabled ? "Enabled" : "Disabled"}</Widget.Text.Primary>
      </Widget.TextWidget>
    )
  },
}

Type Safety

The function’s parameter and return type are automatically inferred from your schema:
app.settings.ts
import {Settings, type SettingsSchema} from "attio"

const appSettingsSchema = {
  workspace: {
    team_name: Settings.string(),
    auto_sync_enabled: Settings.boolean(),
    sync_interval_minutes: Settings.number(),
  },
} satisfies SettingsSchema

export default appSettingsSchema
// TypeScript enforces valid keys and infers return types
await getWorkspaceSetting("team_name") // string
await getWorkspaceSetting("auto_sync_enabled") // boolean
await getWorkspaceSetting("sync_interval_minutes") // number
await getWorkspaceSetting("nonexistent") // TypeScript error!