---
title: "next-intl"
description: "The preset for next-intl and use-intl. It reads useTranslations and getTranslations with their namespaces."
canonical_url: "https://x18n.dev/presets/next-intl"
---
# next-intl

> The preset for next-intl and use-intl. It reads useTranslations and getTranslations with their namespaces.

The `next-intl` preset supports [next-intl](https://next-intl.dev) and use-intl.

## Detection

The preset applies when the project depends on `next-intl` or `use-intl`.

```ts [x18n.config.ts]
import { defineConfig } from '@x18n/core'

export default defineConfig({
  presets: ['next-intl'],
})
```

## Locale files

If your config has no `resources`, the preset uses `messages/{locale}.json` and `src/messages/{locale}.json`.

## Supported syntax

`useTranslations` and `getTranslations` return a translate function. Their argument is a key prefix, which next-intl calls a namespace:

```tsx
import { useTranslations } from 'next-intl'
import { getTranslations } from 'next-intl/server'

function Header() {
  const t = useTranslations('header')
  return <h1>{t('title')}</h1> // header.title
}

async function Page() {
  const t = await getTranslations({ namespace: 'pages.home' })
  return t.rich('intro', {
    b: chunks => <b>{chunks}</b>
  }) // pages.home.intro
}
```

`t`, `t.rich`, `t.markup`, `t.raw` and `t.has` are translate calls. `getTranslations` takes the prefix as a string, or as the `namespace` property of an object.

## Placeholders

ICU MessageFormat: `{name}`, and plural, select and selectordinal arguments such as `{count, plural, one {# item} other {# items}}`. The [`invalid-syntax`](https://x18n.dev/checks/invalid-syntax) check reports unbalanced braces and a plural or select without an `other` case.

## Extraction templates

| Kinds                      | Template                    |
| -------------------------- | --------------------------- |
| `jsx-text`                 | `{t('{key}'{args})}`        |
| `jsx-attribute`            | `{attr}={t('{key}'{args})}` |
| `js-string`, `js-template` | `t('{key}'{args})`          |


## Sitemap

See the full [sitemap](https://x18n.dev/sitemap.md) for all pages.
