Performance: Next-intl library integration
MEDIUM IMPACT
This affects page load speed and interaction responsiveness by how translations are loaded and rendered in Next.js apps.
import {getTranslations} from 'next-intl/server'; export async function generateStaticParams() { return [{locale: 'en'}, {locale: 'fr'}]; } export default async function Page({params}) { const t = await getTranslations(params.locale); return <p>{t('welcome')}</p>; } // Translations loaded server-side or statically
'use client'; import {useTranslations} from 'next-intl'; export default function Page() { const t = useTranslations(); return <p>{t('welcome')}</p>; } // Translations fetched client-side after page load
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side translation fetching | Minimal DOM nodes added | Triggers 1 reflow after translations load | Delays paint by 200-400ms | [X] Bad |
| Server-side or static translation loading | Minimal DOM nodes added | Single reflow during initial paint | Paints immediately with translations | [OK] Good |