Skip to content

Commit 0514f9f

Browse files
authoredMar 4, 2025
fix: use async versions of headers and cookies (#880)
1 parent b93e596 commit 0514f9f

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed
 

‎js-sdk/integrations/react/next/app_router.mdx

+3-3
Original file line numberDiff line numberDiff line change
@@ -164,21 +164,21 @@ import { ALL_LANGUAGES, DEFAULT_LANGUAGE } from './shared';
164164
const LANGUAGE_COOKIE = 'NEXT_LOCALE';
165165

166166
export async function setLanguage(locale: string) {
167-
const cookieStore = cookies();
167+
const cookieStore = await cookies();
168168
cookieStore.set(LANGUAGE_COOKIE, locale, {
169169
maxAge: 1000 * 60 * 60 * 24 * 365, // one year in milisecods
170170
});
171171
}
172172

173173
export async function getLanguage() {
174-
const cookieStore = cookies();
174+
const cookieStore = await cookies();
175175
const locale = cookieStore.get(LANGUAGE_COOKIE)?.value;
176176
if (locale && ALL_LANGUAGES.includes(locale)) {
177177
return locale;
178178
}
179179

180180
// try to detect language from headers or use default
181-
const detected = detectLanguageFromHeaders(headers(), ALL_LANGUAGES);
181+
const detected = detectLanguageFromHeaders(await headers(), ALL_LANGUAGES);
182182
return detected || DEFAULT_LANGUAGE;
183183
}
184184
```

0 commit comments

Comments
 (0)