NuxtN
Nuxt17mo ago
Dovendyret

Nuxt/I18n How to fetch locales as an async function ONLY server-side

Following the official NuxtI18n documentation:
https://i18n.nuxtjs.org/docs/v9/api#definei18nlocale

I've defined a function for fetching my locale messages like this:

export default defineI18nLocale(async () => {
  return await $fetch(`/api/v2/translation/en_GB`)
})


However this function is executed once server-side but also again during client-side hydration. Is there any way to have the fetch only happen server-side? From my understanding it would not be possible to use the useFetch composable in this case.
@nuxtjs/i18n
Composition API for Nuxt i18n module.
Was this page helpful?