How do I pass the next-intl locale to fetchContent so slots come back localized?
Hi everyone! We run a travel marketplace with es, en and fr routes using next-intl. The slot content from fetchContent always comes back in default language, even when user is browsing the /fr routes.
I have the locale available in my server components from the next-intl helpers, I just cannot find where it plugs into the Croct fetch. Is there an option on the call, or some global config I am missing? We would love the marketers to manage the translations too if possible
1 answer
Pass it per call with the preferredLocale option on fetchContent:
import {fetchContent} from '@croct/plug-next/server';import {getLocale} from 'next-intl/server';
const locale = await getLocale();
const content = await fetchContent('home-hero', { preferredLocale: locale, fallback: defaultHeroContent,});That covers everything server-side. On the client, hooks like useContent pick up the provider-level defaultPreferredLocale option, so set that once from the active locale and interactive components follow along.
For the marketer side: per-locale default content is handled by the localization add-on. Your team manages translations per locale directly in the dashboard, so there are no extra routes or content branches to maintain in code. Personalized and localized content resolve together in the same fetch.