Next.js / Setup

Step 12 of 24

Instale e inicie o Altified.

Execute um inicializador a partir da raiz do seu projeto Next.js para configurar a tradução automática do servidor e o encaminhamento de localidades.

Altified supports Next.js 15 or newer with React 18 or newer. The application must use the App Router. Install the package with the same package manager your project already uses.

pnpm
pnpm add @altified/next pnpm exec altified init
npm
npm install @altified/next npx altified init

The initializer detects JavaScript or TypeScript and whether the project uses a src/ directory.

  • Adds missing server-only settings to .env.local.
  • Creates the server client in lib/altified.
  • Creates proxy.js or proxy.ts for locale routing.
  • Wraps the existing Next config with withAltified for automatic JSX translation.

The initializer does not add visible UI or modify your root layout. You place the language switcher yourself in the exact header, navigation, or other component where it belongs.

Read the command output. A Kept line means an existing file or value was preserved. A warning means the initializer could not safely recognize a custom config; follow the manual example in the next step.

When new copy is not discovered

O Next.js regista automaticamente as fontes de tradução durante a compilação da aplicação. Se o conteúdo adicionado recentemente não aparecer, remova o conteúdo gerado. .next Aceda ao diretório e reinicie ou reconstrua a aplicação.
Development
rm -rf .next pnpm dev
Production
rm -rf .next pnpm build pnpm start

Visit the page containing the new copy in the default language and each configured target language. You do not need to run pnpm install or pnpm exec altified init again.