Skip to content

Commit cb93008

Browse files
committed
doc: env variables
1 parent 78fbd7c commit cb93008

File tree

4 files changed

+112
-0
lines changed

4 files changed

+112
-0
lines changed

docs/content/scripts/content/google-maps.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,34 @@ You can add markers to the static and interactive map by providing an array of `
178178

179179
See the [markers](https://github.com/nuxt/scripts/blob/main/playground/pages/third-parties/google-maps/markers.vue) example for more information.
180180

181+
#### With Environment Variables
182+
183+
If you prefer to configure your API key using environment variables.
184+
185+
```ts [nuxt.config.ts]
186+
export default defineNuxtConfig({
187+
scripts: {
188+
registry: {
189+
googleMaps: true,
190+
}
191+
},
192+
// you need to provide a runtime config to access the environment variables
193+
runtimeConfig: {
194+
public: {
195+
scripts: {
196+
googleMaps: {
197+
apiKey: '', // NUXT_PUBLIC_SCRIPTS_GOOGLE_MAPS_API_KEY
198+
},
199+
},
200+
},
201+
},
202+
})
203+
```
204+
205+
```text [.env]
206+
NUXT_PUBLIC_SCRIPTS_GOOGLE_MAPS_API_KEY=<YOUR_API_KEY>
207+
```
208+
181209
### Guides
182210

183211
#### Eager Loading Placeholder

docs/content/scripts/payments/paypal.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,3 +78,31 @@ pnpm add -D @paypal/paypal-js
7878
```
7979

8080
::
81+
82+
#### With Environment Variables
83+
84+
If you prefer to configure your client ID using environment variables.
85+
86+
```ts [nuxt.config.ts]
87+
export default defineNuxtConfig({
88+
scripts: {
89+
registry: {
90+
paypal: true,
91+
}
92+
},
93+
// you need to provide a runtime config to access the environment variables
94+
runtimeConfig: {
95+
public: {
96+
scripts: {
97+
paypal: {
98+
clientId: '', // NUXT_PUBLIC_SCRIPTS_PAYPAL_CLIENT_ID
99+
},
100+
},
101+
},
102+
},
103+
})
104+
```
105+
106+
```text [.env]
107+
NUXT_PUBLIC_SCRIPTS_PAYPAL_CLIENT_ID=<YOUR_CLIENT_ID>
108+
```

docs/content/scripts/support/crisp.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,34 @@ See the [Facade Component API](/docs/guides/facade-components#facade-components-
104104

105105
See the [Config Schema](#config-schema) for full details.
106106

107+
#### With Environment Variables
108+
109+
If you prefer to configure your id using environment variables.
110+
111+
```ts [nuxt.config.ts]
112+
export default defineNuxtConfig({
113+
scripts: {
114+
registry: {
115+
crisp: true,
116+
}
117+
},
118+
// you need to provide a runtime config to access the environment variables
119+
runtimeConfig: {
120+
public: {
121+
scripts: {
122+
crisp: {
123+
id: '', // NUXT_PUBLIC_SCRIPTS_CRISP_ID
124+
},
125+
},
126+
},
127+
},
128+
})
129+
```
130+
131+
```text [.env]
132+
NUXT_PUBLIC_SCRIPTS_CRISP_ID=<YOUR_ID>
133+
```
134+
107135
### Events
108136

109137
The `ScriptCrisp` component emits a single `ready` event when crisp is loaded.

docs/content/scripts/support/intercom.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,34 @@ See the [Facade Component API](/docs/guides/facade-components#facade-components-
8787

8888
See the [Config Schema](#config-schema) for full details.
8989

90+
#### With Environment Variables
91+
92+
If you prefer to configure your app ID using environment variables.
93+
94+
```ts [nuxt.config.ts]
95+
export default defineNuxtConfig({
96+
scripts: {
97+
registry: {
98+
intercom: true,
99+
}
100+
},
101+
// you need to provide a runtime config to access the environment variables
102+
runtimeConfig: {
103+
public: {
104+
scripts: {
105+
intercom: {
106+
app_id: '', // NUXT_PUBLIC_SCRIPTS_INTERCOM_APP_ID
107+
},
108+
},
109+
},
110+
},
111+
})
112+
```
113+
114+
```text [.env]
115+
NUXT_PUBLIC_SCRIPTS_INTERCOM_APP_ID=<YOUR_APP_ID>
116+
```
117+
90118
### Events
91119

92120
The `ScriptIntercom` component emits a single `ready` event when Intercom is loaded.

0 commit comments

Comments
 (0)