• Documentation
  • Guide
  • Next.js I18n

Next.js I18n

⚠️
This feature is only available in the docs theme.

Nextra supports Next.js Internationalized Routing out of the box.

To add multi-language pages to your Nextra application, you need to config i18n in next.config.js first:

next.config.js
const withNextra = require('nextra')('nextra-theme-docs', './theme.config.jsx')
module.exports = withNextra({
  i18n: {
    locales: ['en', 'zh', 'de'],
    defaultLocale: 'en'
  }
})

Then, add the locale codes to your file extensions (required for the default locale too):

/pages
  _meta.en.json
  _meta.zh.json
  _meta.de.json
  index.en.md
  index.zh.md
  index.de.md
  ...

Finally, add the i18n option to your theme.config.jsx to configure the language dropdown:

theme.config.jsx
i18n: [
  { locale: 'en', text: 'English' },
  { locale: 'zh', text: '中文' },
  { locale: 'de', text: 'Deutsch' },
  { locale: 'ar', text: 'العربية', direction: 'rtl' }
]