The experimental_getWorkspaceSetting() function retrieves a single workspace setting value by key.
// In client code (React components, actions, etc.)
import { experimental_getWorkspaceSetting } from "attio/client";
// In server functions
import { experimental_getWorkspaceSetting } from "attio/server";
For React components, consider using experimental_useWorkspaceSettings() instead, which provides real-time updates when settings change.
The Workspace Settings API is experimental and may change in the future. Please don’t use it in production versions of your app.
Parameters
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 { experimental_getWorkspaceSetting } from "attio/server";
export default async function checkSyncStatus() {
// Get a single setting value
const autoSyncEnabled = await experimental_getWorkspaceSetting("auto_sync_enabled");
// TypeScript knows this is a boolean
if (autoSyncEnabled) {
const syncInterval = await experimental_getWorkspaceSetting("sync_interval_minutes");
// TypeScript knows this is a number
return {
status: "enabled",
interval: syncInterval
};
}
return { status: "disabled" };
}
In Client Code
import { experimental_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 experimental_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:
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 experimental_getWorkspaceSetting("team_name"); // string
await experimental_getWorkspaceSetting("auto_sync_enabled"); // boolean
await experimental_getWorkspaceSetting("sync_interval_minutes"); // number
await experimental_getWorkspaceSetting("nonexistent"); // TypeScript error!