Next.js Setup
Install the adapter
Section titled “Install the adapter”npm install tyndale-nextConfiguration
Section titled “Configuration”-
Update your Next.js config
next.config.mjs import { withTyndaleConfig } from 'tyndale-next/config';export default withTyndaleConfig({// your existing Next.js config}); -
Add the middleware
middleware.ts import { createTyndaleMiddleware } from 'tyndale-next/middleware';export default createTyndaleMiddleware();export const config = {matcher: ['/((?!api|_next|_tyndale|.*\\..*).*)'],};This handles locale detection, redirects to locale-prefixed routes, and persists the active locale in a cookie.
-
Add the server provider to your layout
app/[locale]/layout.tsx import { getDirection, TyndaleServerProvider } from 'tyndale-next/server';export default async function RootLayout({children,params,}: {children: React.ReactNode;params: Promise<{ locale: string }>;}) {const { locale } = await params;return (<html lang={locale} dir={getDirection(locale)}><body><TyndaleServerProvider locale={locale}>{children}</TyndaleServerProvider></body></html>);}TyndaleServerProviderloads locale data on the server. Set<html dir>yourself withgetDirection(locale)in server components oruseDirection()in client components.
How it works
Section titled “How it works”withTyndaleConfigreadstyndale.config.json, injects the build-time env vars Tyndale uses at runtime, and aliasestyndale-reactso your app shares a single provider context- The middleware redirects requests to locale-prefixed routes, normalizes locale aliases, and sets the locale cookie/header for downstream rendering
TyndaleServerProviderloads translations server-side and makes them available to all components via React context