Skip to main content

useSettings

Returns the current Admin-level settings. Values reflect the <Settings> props passed to <Admin>, merged over the framework's built-in defaults.

import { useSettings } from '@strato-admin/core';

const { listComponent, detailComponent, deleteSuccessMessage } = useSettings();

Signature

function useSettings(): AdminSettings;

AdminSettings

interface AdminSettings {
listComponent?: ComponentType<any>;
detailComponent?: ComponentType<any>;
deleteSuccessMessage?: string | ReactNode;
bulkDeleteSuccessMessage?: string | ReactNode | ((count: number) => ReactNode);
}

All fields are optional — the hook returns an empty object {} when called outside an <Admin> tree, and the full merged defaults when called inside one.

Example

Render a custom action that uses the same list component as the rest of the app:

import { useSettings } from '@strato-admin/core';

const ResourcePreview = ({ resource }: { resource: string }) => {
const { listComponent: ListComponent } = useSettings();

if (!ListComponent) return null;
return <ListComponent resource={resource} />;
};

Framework defaults

When no <Settings> prop is provided to <Admin>, the framework defaults apply:

SettingDefault
listComponent<Table>
detailComponent<DetailHub>
deleteSuccessMessage"Element deleted"
bulkDeleteSuccessMessage"{count} elements deleted" (ICU plural)

See <Settings> for how to override these values.

Building components that respect settings

When building a component that accepts a local prop but should fall back to the global setting, use useSettingValue instead of reading useSettings directly.