Performance: Server component translations
MEDIUM IMPACT
This affects the initial page load speed by offloading translation rendering to the server, reducing client-side JavaScript and improving Largest Contentful Paint (LCP).
import { getTranslations } from '@/lib/i18n'; export default async function Greeting({ params }) { const t = await getTranslations(params.locale); return <p>{t('hello')}</p>; }
import { useTranslation } from 'next-i18next/client'; export default function Greeting() { const { t } = useTranslation(); return <p>{t('hello')}</p>; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Client-side translation in React component | Moderate (due to hydration) | 1 reflow after hydration | Higher paint cost due to delayed content | [X] Bad |
| Server component translation rendering | Minimal (static HTML) | 0 reflows on load | Lower paint cost, faster LCP | [OK] Good |