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/next2. 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_KEY4. 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.jsonOptions
| Option | Required | Description |
|---|---|---|
source | Yes | Path to source translation file |
lang | Yes | Target language codes |
project | No | Project for glossary and style guide (owner/repo format) |
sourceLanguage | No | Source language (default: auto-detect from filename) |
apiKey | No | API key (default: AUTOGLOT_API_KEY env var) |
skipCache | No | Skip 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.