Next.js plugin

The @autoglot/next plugin wraps your Next.js config so translations run after every production build — no manual step needed. Works with both webpack and Turbopack.

1. Install the package

bash
npm install @autoglot/next

2. Configure next.config.mjs

javascript
// next.config.mjs
import { withAutoglot } from '@autoglot/next';

export default withAutoglot({
  source: 'src/locales/en.json',
  lang: ['es', 'fr', 'de', 'ja', 'pt'],
  project: 'myorg/my-app',  // optional — uses your project glossary
})({
  // your existing Next.js config
});

3. Set your API key

Add AUTOGLOT_API_KEY to your hosting provider (Vercel, Netlify, etc.) or .env.local:

bash
vercel env add AUTOGLOT_API_KEY

4. Gitignore generated files

Only commit the source language file. Generated translations are created fresh on every build:

yaml
# .gitignore
src/locales/*.json
!src/locales/en.json

Options

OptionRequiredDescription
sourceYesPath to source translation file
langYesTarget language codes
projectNoProject for glossary and style guide (owner/repo format)
sourceLanguageNoSource language (default: auto-detect from filename)
apiKeyNoAPI key (default: AUTOGLOT_API_KEY env var)
skipCacheNoSkip translation cache (default: false)

Composing with other plugins

javascript
import { withAutoglot } from '@autoglot/next';
import createMDX from '@next/mdx';

const withMDX = createMDX();

export default withAutoglot({
  source: 'src/locales/en.json',
  lang: ['es', 'fr', 'de'],
})(withMDX({
  pageExtensions: ['js', 'jsx', 'mdx', 'ts', 'tsx'],
}));

The plugin hooks into Next.js 15.4.1+ runAfterProductionCompile, or falls back to a webpack done hook for older versions. Translations only run during next build, not next dev.