Runtime config lets you inject values into your app at server startup time, without a rebuild. You define default values inDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dvlkit/nuxe/llms.txt
Use this file to discover all available pages before exploring further.
nuxe.config.ts, and any of those values can be overridden by NUXE_* environment variables when the server starts. Nuxe automatically generates TypeScript types for your config so that useRuntimeConfig() is fully typed throughout your project.
Defining runtime config
Declare defaults underruntimeConfig in nuxe.config.ts. Top-level keys are server-only. Keys nested under public are also sent to the client.
nuxe.config.ts
Reading runtime config
CalluseRuntimeConfig() inside any Vue <script setup>, composable, or plugin. It returns a typed RuntimeConfig object whose shape is derived from your nuxe.config.ts.
The RuntimeConfig type is defined as:
useRuntimeConfig() is narrowed to the exact shape of your declared keys.
useRuntimeConfig() uses Vue’s inject internally. It is safe to call anywhere that has an active injection context (setup functions, plugins, composables called from setup). Outside of a Vue context it returns an empty config ({ public: {} }).
Client vs. server availability
On the server,useRuntimeConfig() returns the full config including all top-level private keys. On the client, only the public sub-object is available — private keys are stripped from the browser payload before the page is sent. Never rely on top-level keys being present in client-side code.
Environment variable overrides
Nuxe maps everyNUXE_* environment variable to a runtime config key using the following rules:
- camelCase config keys map to UPPER_SNAKE_CASE env var suffixes — for example
dbUrl→NUXE_DB_URL - Keys under
publicuse the prefixNUXE_PUBLIC_— for examplepublic.apiBase→NUXE_PUBLIC_API_BASE - Nested keys use
_as a separator at each level - Boolean strings
"true"and"false"are coerced toboolean - Strings that match the pattern
/^-?\d+$/are coerced tonumber - All other string values are kept as strings
Playground example
| Config key | Environment variable |
|---|---|
apiSecret | NUXE_API_SECRET |
public.apiBase | NUXE_PUBLIC_API_BASE |
Two-pass resolution
Nuxe resolves runtime config in two passes:- Declared keys — any
NUXE_*env var whose name matches a key already present in your config is applied first. - Undeclared keys — any remaining
NUXE_*env vars that did not match a declared key are injected automatically, creating new keys at runtime.
nuxe.config.ts.
Reserved environment variables
The followingNUXE_* names are used internally by Nuxe and must not be used as runtime config keys:
NUXE_SILENT
Suppresses Nuxe’s console output when set.
NUXE_DEV
Signals that Nuxe is running in development mode.
NUXE_BASE_URL
Sets the base URL for server-side
useFetch. Overrides config.baseUrl.NUXE_VITE_NODE_OPTIONS
Node.js options forwarded to the Vite child process.
Type generation
When Nuxe starts (dev or build), it inspects your resolvedruntimeConfig and writes a TypeScript declaration file to .nuxe/runtime-config.d.ts. This file contains:
- A concrete
RuntimeConfiginterface shaped exactly like your config - Module augmentation for
@dvlkit/nuxeand@dvlkit/nuxe/runtimeso thatuseRuntimeConfig()returns the typed interface everywhere
.nuxe/runtime-config.d.ts
The
.nuxe/ directory is generated automatically. You should add it to
.gitignore. The types are regenerated on every nuxe dev and nuxe build
invocation, so they always reflect your current config.