Helpers
useSetLocale
API reference for the useSetLocale hook
Overview
The useSetLocale hook is used to set the user’s locale.
This is client-side only and must be wrapped in a <GTProvider> component.
Reference
Returns
A function that sets the user’s locale.
Examples
Basic usage
import { useSetLocale } from 'gt-next/client';
export default function MyComponent() {
const setLocale = useSetLocale();
return (
<button onClick={() => setLocale('en')}>Set locale</button>
);
}Notes
useSetLocaleis used to set the user’s locale.- Learn more about locale strings here.
Next steps
- Learn more about the
<GTProvider>component. - Learn more about the
useLocalehook.
How is this guide?