Cookie store is empty
Unanswered
Palomino posted this in #help-forum
PalominoOP
Hello, I am using next-intl and I am following everything the docs tell you to do, I've never had this issue before except this time maybe because I am using PayloadCMS?
The function doesn't error or anything, it works fine except that it returns an empty array as if I have no cookies set
It's important to note that if I try to access the same thing in a server function it works just fine and I have 0 issues
import type { Locale } from 'next-intl'
import { getRequestConfig } from 'next-intl/server'
import { cookies } from 'next/headers'
export const locales = ['en', 'ar', 'fr'] as const
export default getRequestConfig(async () => {
const cookieStore = await cookies()
const locale = (cookieStore.get('locale')?.value as Locale) || 'ar'
return {
locale,
messages: (await import(`../../messages/${locale}.json`)).default,
}
})The function doesn't error or anything, it works fine except that it returns an empty array as if I have no cookies set
It's important to note that if I try to access the same thing in a server function it works just fine and I have 0 issues
3 Replies
Are you using the next-intl plugin in next.config.ts ?
import createNextIntlPlugin from 'next-intl/plugin'
const withNextIntl = createNextIntlPlugin()
export default withNextIntl({....nextjs config...})
import createNextIntlPlugin from 'next-intl/plugin'
const withNextIntl = createNextIntlPlugin()
export default withNextIntl({....nextjs config...})
PalominoOP
yes i am
Giant Angora
I think I encountered the same problem.
I guess you are using the provider in client.
The provider should be used with a server component so the messages and request will be accessed on the client
I guess you are using the provider in client.
The provider should be used with a server component so the messages and request will be accessed on the client