API
useConfig
ReactVanilla
The frozen effective config — locales, units, currencies, detection order — for components that need to read settings without subscribing to state.
useConfig(): Readonly<StiftRuntimeConfig>
No arguments, no subscription. The object is frozen at boot; reading it never re-renders, so it is safe in hot paths and outside reactive contexts that only need static lists.
Returns
The normalized runtime config: locales.supported (the typed locale union — build switchers from this, never a hardcoded list), currencies, unit categories, detection order, and everything stift.config.ts declares, resolved with defaults.
Examples
function LocaleSwitcher() {
const supported = useConfig().locales.supported
const { locale, setLocale } = useLocale()
return (
<select value={locale} onChange={(e) => setLocale(e.target.value)}>
{supported.map((l) => (
<option key={l} value={l}>{l}</option>
))}
</select>
)
}
Next
- Writing the config → stift.config.ts
- Reactive locale state →
useLocale