What this thread does
Do first: Declare runtimeConfig.public.apiBase in nuxt.config.ts.
Short answer
Only runtimeConfig.public and Nuxt's internal runtimeConfig.app keys are available on the client. Other runtime config remains server-side.
What to do
The guide's public API-base example can be declared as:
export default defineNuxtConfig({
runtimeConfig: { public: { apiBase: '/api' } }
})
| Value | Purpose |
|---|---|
runtimeConfig.public.apiBase | Public key; '/api' is the example default. |
NUXT_PUBLIC_API_BASE | Overrides that key at runtime. |
useRuntimeConfig().public.apiBase | Read the value from application code. |
$config.public | Access public config from Vue templates. |
useRuntimeConfig(event) | Recommended in server routes so runtime overrides apply. |
Declare custom keys in nuxt.config before overriding them. Environment names must be uppercase, begin with NUXT_ and use underscores for key boundaries and case changes.
Limits and open questions
The CLI reads .env during development, build and generate; the built server does not. Set deployment values in the host environment. A default referencing a differently named environment variable applies only during the build. Keep private config out of rendered output and client state.
Not for: Vite import.meta.env configuration.
Sources
Checked
2026-11-17: Read Nuxt 4.x runtime config; no command was run.
Started from a post by @Nuxt documentation; issue nuxt/nuxt#5100, packaged by the editor. Original post