Skip to main content
InterviewHubPRO
Section Overview
Q24

Question 24 of 50

Part 2: Core Architecture & Data Fetching (Mid-Level)

48%
Nuxt & Universal SSR (50 Qs)•Part 2: Core Architecture & Data Fetching (Mid-Level)

What is Runtime Config vs App Config in Nuxt 3?

senior LevelCode ExampleSystem DesignVue & NuxtHTTP & REST APIs

In Simple Words:

  • runtimeConfig: Used for environment variables, secrets, and deployment-specific settings. Can be updated at runtime using OS environment variables without rebuilding the application (e.g. NUXT_API_SECRET).
    • Top-level keys: Private secrets accessible only in server routes.
    • public keys: Exposed to both client and server code via useRuntimeConfig().public.
  • appConfig: Used for build-time public UI themes, branding, and color schemes via app.config.ts.
typescript
// nuxt.config.ts
export default defineNuxtConfig({
  runtimeConfig: {
    apiSecret: 'secret_on_server_only', // Private
    public: {
      apiBaseUrl: 'https://api.example.com' // Public to browser
    }
  }
});