Runtime config

Some options can be set via the runtimeConfig, setting options this way makes it possible to override these after building using environment variables.


Usage

If you want to use environment variables to change supported options, you will have to set these in runtimeConfig.public.i18n.

The module configuration takes precedence, options set through runtimeConfig will only be used if they are unset.

Setting baseUrl through runtimeConfig would look like this:

nuxt.config.ts
export default defineNuxtConfig({
runtimeConfig: {
public: {
i18n: {
baseUrl: 'https://example.com',
}
}
},
modules: [
'@nuxtjs/i18n'
],
i18n: {
// Leave options unset that you want to set using `runtimeConfig`
// baseUrl: 'https://example.com',
}
})

With this configuration you will be able to override the baseUrl option by setting the NUXT_PUBLIC_I18N_BASE_URL environment variable. You can read more about how this works in the Nuxt documentation.

Supported options

These options can be set using runtimeConfig:

Only serializable values are supported in runtimeConfig, options set this way may not support all available types (such as functions) as would normally be possible using the default configuration.
If you would like other options to be supported, open an issue describing your use case, or open a PR adding to add support yourself!
Table of Contents