From ac08ac639d269d2ab74a5e2788aed4adb2e38fc6 Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Mon, 24 Oct 2022 09:35:51 +0200 Subject: [PATCH 1/6] docs: add note about de/-serializability of runtime config --- docs/content/2.guide/4.going-further/10.runtime-config.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/content/2.guide/4.going-further/10.runtime-config.md b/docs/content/2.guide/4.going-further/10.runtime-config.md index 38c8dc13db4..473de1b459b 100644 --- a/docs/content/2.guide/4.going-further/10.runtime-config.md +++ b/docs/content/2.guide/4.going-further/10.runtime-config.md @@ -39,6 +39,10 @@ console.log(runtimeConfig.public.apiBase) When using Options API the public runtime config is available via `this.$config.public`. :: +### Serialization + +Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that values that cannot be serialized and then correctly deserialized (e.g., functions), will not be available as the original value they were defined as inside your runtime config. If you want to pass values into your application that are not the same after a de/-serialization you can write runtime code that creates these more complex values based on a serializable runtime config. + ### Environment Variables The most common way to provide configuration is by using [Environment Variables](https://medium.com/chingu/an-introduction-to-environment-variables-and-how-to-use-them-f602f66d15fa). From 607d2279f1604a90e4425948a5c1da99308b76a6 Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Mon, 24 Oct 2022 09:38:01 +0200 Subject: [PATCH 2/6] docs: clarify position of configs --- docs/content/2.guide/4.going-further/10.runtime-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2.guide/4.going-further/10.runtime-config.md b/docs/content/2.guide/4.going-further/10.runtime-config.md index 473de1b459b..23e21911955 100644 --- a/docs/content/2.guide/4.going-further/10.runtime-config.md +++ b/docs/content/2.guide/4.going-further/10.runtime-config.md @@ -41,7 +41,7 @@ When using Options API the public runtime config is available via `this.$config. ### Serialization -Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that values that cannot be serialized and then correctly deserialized (e.g., functions), will not be available as the original value they were defined as inside your runtime config. If you want to pass values into your application that are not the same after a de/-serialization you can write runtime code that creates these more complex values based on a serializable runtime config. +Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that runtime config that cannot be serialized and then correctly deserialized (e.g., functions), will not be available in your app as the original value they were defined as inside your `nuxt.config`. If you want to pass values into your application that are not the same after a de/-serialization you can write runtime code that creates these more complex values based on a serializable runtime config. ### Environment Variables From 04ebe59c8db4ebb1d5771ad8d9b756b737a0f608 Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Mon, 24 Oct 2022 09:40:13 +0200 Subject: [PATCH 3/6] docs: fix dash placement + add paragraph --- docs/content/2.guide/4.going-further/10.runtime-config.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/content/2.guide/4.going-further/10.runtime-config.md b/docs/content/2.guide/4.going-further/10.runtime-config.md index 23e21911955..4c162e5c338 100644 --- a/docs/content/2.guide/4.going-further/10.runtime-config.md +++ b/docs/content/2.guide/4.going-further/10.runtime-config.md @@ -41,7 +41,9 @@ When using Options API the public runtime config is available via `this.$config. ### Serialization -Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that runtime config that cannot be serialized and then correctly deserialized (e.g., functions), will not be available in your app as the original value they were defined as inside your `nuxt.config`. If you want to pass values into your application that are not the same after a de/-serialization you can write runtime code that creates these more complex values based on a serializable runtime config. +Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that runtime config that cannot be serialized and then correctly deserialized (e.g., functions), will not be available in your app as the original value they were defined as inside your `nuxt.config`. + +If you want to pass values into your application that are not the same after a de-/serialization you can write runtime code that creates these more complex values (e.g., functions) based on a serializable runtime config. ### Environment Variables From 93ee10da7c69e6da001171a45bd6992fd33731d0 Mon Sep 17 00:00:00 2001 From: BracketJohn Date: Mon, 24 Oct 2022 09:43:53 +0200 Subject: [PATCH 4/6] docs: trim trailing whitespace --- docs/content/2.guide/4.going-further/10.runtime-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2.guide/4.going-further/10.runtime-config.md b/docs/content/2.guide/4.going-further/10.runtime-config.md index 4c162e5c338..a00f9162c7f 100644 --- a/docs/content/2.guide/4.going-further/10.runtime-config.md +++ b/docs/content/2.guide/4.going-further/10.runtime-config.md @@ -41,7 +41,7 @@ When using Options API the public runtime config is available via `this.$config. ### Serialization -Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that runtime config that cannot be serialized and then correctly deserialized (e.g., functions), will not be available in your app as the original value they were defined as inside your `nuxt.config`. +Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that runtime config that cannot be serialized and then correctly deserialized (e.g., functions), will not be available in your app as the original value they were defined as inside your `nuxt.config`. If you want to pass values into your application that are not the same after a de-/serialization you can write runtime code that creates these more complex values (e.g., functions) based on a serializable runtime config. From b08995a137d38fd85c082ebe4c8b5f866dae6549 Mon Sep 17 00:00:00 2001 From: Nils Date: Mon, 24 Oct 2022 10:20:58 +0200 Subject: [PATCH 5/6] docs: more clearly state what cannot be correctly passed down Co-authored-by: Daniel Roe --- docs/content/2.guide/4.going-further/10.runtime-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2.guide/4.going-further/10.runtime-config.md b/docs/content/2.guide/4.going-further/10.runtime-config.md index a00f9162c7f..92ea53cfbad 100644 --- a/docs/content/2.guide/4.going-further/10.runtime-config.md +++ b/docs/content/2.guide/4.going-further/10.runtime-config.md @@ -41,7 +41,7 @@ When using Options API the public runtime config is available via `this.$config. ### Serialization -Internally, the runtime config is intentionally serialized and then deserialized again by nuxt. This means that runtime config that cannot be serialized and then correctly deserialized (e.g., functions), will not be available in your app as the original value they were defined as inside your `nuxt.config`. +Your runtime config will be serialized before being passed to Nitro. This means that anything that cannot be serialized and then deserialized (such as functions, Sets, Maps, and so on), should not be set in your `nuxt.config`. If you want to pass values into your application that are not the same after a de-/serialization you can write runtime code that creates these more complex values (e.g., functions) based on a serializable runtime config. From 7586e1de45fba415bf399874d304c9e30d046c65 Mon Sep 17 00:00:00 2001 From: Nils Date: Mon, 24 Oct 2022 10:21:23 +0200 Subject: [PATCH 6/6] docs: more clearly describe alternative Co-authored-by: Daniel Roe --- docs/content/2.guide/4.going-further/10.runtime-config.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/content/2.guide/4.going-further/10.runtime-config.md b/docs/content/2.guide/4.going-further/10.runtime-config.md index 92ea53cfbad..63bff930dca 100644 --- a/docs/content/2.guide/4.going-further/10.runtime-config.md +++ b/docs/content/2.guide/4.going-further/10.runtime-config.md @@ -43,7 +43,7 @@ When using Options API the public runtime config is available via `this.$config. Your runtime config will be serialized before being passed to Nitro. This means that anything that cannot be serialized and then deserialized (such as functions, Sets, Maps, and so on), should not be set in your `nuxt.config`. -If you want to pass values into your application that are not the same after a de-/serialization you can write runtime code that creates these more complex values (e.g., functions) based on a serializable runtime config. +Instead of passing non-serializable objects or functions into your application from your `nuxt.config`, you can place this code in a Nuxt or Nitro plugin or middleware. ### Environment Variables