> For AI agents: the complete documentation index is available at https://rspress.rs/llms.txt, the full documentation bundle is available at https://rspress.rs/llms-full.txt.

# useI18n

`useI18n` lets you read localized text inside custom components using the configured source. For setup details, see [config.i18nSource](https://rspress.rs/api/config/config-basic.md#i18nsource).

Rspress provides the [`useI18n`](https://rspress.rs/ui/hooks/use-i18n.md) hook to get the internationalized text, the usage is as follows:

```tsx
import { useI18n } from '@rspress/core/runtime';

const MyComponent = () => {
  const t = useI18n();

  return <div>{t('gettingStarted')}</div>;
};
```

For better type hinting, you can configure `paths` in tsconfig.json:

```json
{
  "compilerOptions": {
    "paths": {
      "i18n": ["./i18n.json"]
    }
  }
}
```

Then use it like this in the component:

```tsx
import { useI18n } from '@rspress/core/runtime';

const MyComponent = () => {
  const t = useI18n<typeof import('i18n')>();

  return <div>{t('gettingStarted')}</div>;
};
```

This way you get type hints for all text keys defined in `i18n.json`.
