feat: 위키 저장소 초기 커밋
- CLAUDE.md 운영 규칙 - wiki/ 정리된 지식 페이지 (Nuxt + Claude Code) - raw/ 원본 자료 - reference/ Nuxt 4.x 공식 문서 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
38
reference/6.bridge/7.runtime-config.md
Normal file
38
reference/6.bridge/7.runtime-config.md
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
title: Runtime Config
|
||||
description: 'Nuxt provides a runtime config API to expose configuration and secrets within your application.'
|
||||
---
|
||||
|
||||
::warning
|
||||
When using `runtimeConfig` option, [nitro](/docs/4.x/bridge/nitro) must have been configured.
|
||||
::
|
||||
|
||||
## 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
|
||||
- <div>Website: {{ $config.websiteURL }}</div>
|
||||
+ <div>Website: {{ $config.public.websiteURL }}</div>
|
||||
```
|
||||
Reference in New Issue
Block a user