Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions js-sdk/integrations/react/next/app_router.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,21 @@ import { ALL_LANGUAGES, DEFAULT_LANGUAGE } from './shared';
const LANGUAGE_COOKIE = 'NEXT_LOCALE';

export async function setLanguage(locale: string) {
const cookieStore = cookies();
const cookieStore = await cookies();
cookieStore.set(LANGUAGE_COOKIE, locale, {
maxAge: 1000 * 60 * 60 * 24 * 365, // one year in milisecods
});
}

export async function getLanguage() {
const cookieStore = cookies();
const cookieStore = await cookies();
const locale = cookieStore.get(LANGUAGE_COOKIE)?.value;
if (locale && ALL_LANGUAGES.includes(locale)) {
return locale;
}

// try to detect language from headers or use default
const detected = detectLanguageFromHeaders(headers(), ALL_LANGUAGES);
const detected = detectLanguageFromHeaders(await headers(), ALL_LANGUAGES);
return detected || DEFAULT_LANGUAGE;
}
```
Expand Down