Skip to content

Commit a60b0ca

Browse files
committed
docs: properly mention how to use the runtime config (#107)
Closes #107
1 parent 3b182a1 commit a60b0ca

File tree

1 file changed

+9
-23
lines changed

1 file changed

+9
-23
lines changed

docs/content/1.setup/2.configuration.md

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,16 @@ export default defineNuxtConfig({
2525
| `clients.[client].query` | `SearchParameters` | | Adds query search params to URL |
2626
| `clients.[client].schema` | `OpenAPI3Schema` | | Local or remote schema file (YAML or JSON) |
2727

28-
Client can also be configured using `runtimeConfig` or environment variables:
28+
## Runtime configuration
29+
30+
All options, except `schema`, are automatically copied to the runtime config.
31+
32+
::note
33+
You can access and modify these options at runtime using [`useRuntimeConfig()`](https://nuxt.com/docs/4.x/api/composables/use-runtime-config).
34+
::
35+
36+
This is particularly useful for overriding settings with **environment variables**. For example:
2937

30-
```ts twoslash [nuxt.config.ts]
31-
// @noErrors
32-
export default defineNuxtConfig({
33-
openFetch: {
34-
clients: {
35-
pets: {} // The key should be specified as it is used to generate the client
36-
}
37-
},
38-
runtimeConfig: {
39-
public: {
40-
openFetch: {
41-
pets: {
42-
schema: 'https://petstore3.swagger.io/api/v3/openapi.json',
43-
baseURL: 'https://petstore3.swagger.io/api/v3/'
44-
},
45-
},
46-
}
47-
},
48-
})
49-
```
50-
or:
5138
```dotenv [.env]
52-
NUXT_PUBLIC_OPEN_FETCH_PETS_SCHEMA=https://petstore3.swagger.io/api/v3/openapi.json
5339
NUXT_PUBLIC_OPEN_FETCH_PETS_BASE_URL=https://petstore3.swagger.io/api/v3/
5440
```

0 commit comments

Comments
 (0)