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

  • useSetLocale is used to set the user’s locale.
  • Learn more about locale strings here.

Next steps

How is this guide?

useSetLocale