From 198576a741d74072c93963e1b7eb2448385ae52b Mon Sep 17 00:00:00 2001 From: Josh Deltener Date: Mon, 26 Sep 2022 04:37:31 -0500 Subject: [PATCH] docs: updated nuxt bridge migration guide (#7775) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sébastien Chopin Co-authored-by: Daniel Roe --- docs/content/bridge/1.overview.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/docs/content/bridge/1.overview.md b/docs/content/bridge/1.overview.md index 62853bd533..aec21984ba 100644 --- a/docs/content/bridge/1.overview.md +++ b/docs/content/bridge/1.overview.md @@ -149,6 +149,36 @@ Overwriting options such as `"compilerOptions.paths"` with your own configuratio In case you need to extend options provided by `./.nuxt/tsconfig.json` further, you can use the `alias` property withing your `nuxt.config`. `nuxi` will pick them up and extend `./.nuxt/tsconfig.json` accordingly. :: +## Update Runtime Config + +Nuxt 3 approaches runtime config differently than Nuxt 2, using a new combined `runtimeConfig` option. + +First, you'll need to combine your `publicRuntimeConfig` and `privateRuntimeConfig` properties into a new one called `runtimeConfig`, with the public config within a key called `public`. + +```diff +// nuxt.config.js +- privateRuntimeConfig: { +- apiKey: process.env.NUXT_API_KEY || 'super-secret-key' +- }, +- publicRuntimeConfig: { +- websiteURL: 'https://public-data.com' +- } ++ runtimeConfig: { ++ apiKey: process.env.NUXT_API_KEY || 'super-secret-key', ++ public: { ++ websiteURL: 'https://public-data.com' ++ } ++ } +``` + +This also means that when you need to access public runtime config, it's behind a property called `public`. If you use public runtime config, you'll need to update your code. + +```diff +// MyWidget.vue +-
Website: {{ $config.websiteURL }}
++
Website: {{ $config.public.websiteURL }}
+``` + ## Migrate Composition API If you were using `@vue/composition-api` or `@nuxtjs/composition-api`, please read the [composition api migration guide](/bridge/bridge-composition-api).