diff --git a/packages/schema/src/config/_common.ts b/packages/schema/src/config/_common.ts index 50d822f43c..a936bac5d9 100644 --- a/packages/schema/src/config/_common.ts +++ b/packages/schema/src/config/_common.ts @@ -678,23 +678,22 @@ export default { /** * Runtime config allows passing dynamic config and environment variables to the Nuxt app context. - * - * It is added to the Nuxt payload so there is no need to rebuild to update your configuration in - * development or if your application is served by the Nuxt server. (For static sites you will still - * need to regenerate your site to see changes.) - * - * The value of this object is accessible from server only using `$config`. - * + * + * The value of this object is accessible from server only using `$config` or `useRuntimeConfig`. * It will override `publicRuntimeConfig` on the server-side. * * It should hold _private_ environment variables (that should not be exposed on the frontend). * This could include a reference to your API secret tokens. + * + * Values are automatically replaced by matching env variables at runtime, e.g. setting an environment + * variable `API_SECRET=my-api-key` would overwrite the value in the example below. + * Note that the env variable has to be named exactly the same as the config key. * * @example * ```js * export default { * privateRuntimeConfig: { - * apiSecret: process.env.API_SECRET + * API_SECRET: '' // Default to an empty string, automatically loaded at runtime using process.env.API_SECRET * } * } * ``` @@ -706,20 +705,21 @@ export default { /** * Runtime config allows passing dynamic config and environment variables to the Nuxt app context. - * - * It is added to the Nuxt payload so there is no need to rebuild to update your configuration in - * development or if your application is served by the Nuxt server. (For static sites you will still - * need to regenerate your site to see changes.) - * - * The value of this object is accessible from both client and server using `$config`. It should hold env - * variables that are _public_ as they will be accessible on the frontend. This could include a + * + * The value of this object is accessible from both client and server using `$config` or `useRuntimeConfig`. + * + * It should hold env variables that are _public_ as they will be accessible on the frontend. This could include a * reference to your public URL. * + * Values are automatically replaced by matching env variables at runtime, e.g. setting an environment + * variable `BASE_URL=https://some-other-url.org` would overwrite the value in the example below. + * Note that the env variable has to be named exactly the same as the config key. + * * @example * ```js * export default { * publicRuntimeConfig: { - * baseURL: process.env.BASE_URL || 'https://nuxtjs.org' + * BASE_URL: 'https://nuxtjs.org' * } * } * ```