Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
Comprehensive Nuxt 3.x reference covering SSR, file-based routing, auto-imports, server routes, and Nitro deployment.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
references/core-config.md
1---2name: configuration3description: Nuxt configuration files including nuxt.config.ts, app.config.ts, and runtime configuration4---56# Nuxt Configuration78Nuxt uses configuration files to customize application behavior. The main configuration options are `nuxt.config.ts` for build-time settings and `app.config.ts` for runtime settings.910## nuxt.config.ts1112The main configuration file at the root of your project:1314```ts15// nuxt.config.ts16export default defineNuxtConfig({17// Configuration options18devtools: { enabled: true },19modules: ['@nuxt/ui'],20})21```2223### Environment Overrides2425Configure environment-specific settings:2627```ts28export default defineNuxtConfig({29$production: {30routeRules: {31'/**': { isr: true },32},33},34$development: {35// Development-specific config36},37$env: {38staging: {39// Staging environment config40},41},42})43```4445Use `--envName` flag to select environment: `nuxt build --envName staging`4647## Runtime Config4849For values that need to be overridden via environment variables:5051```ts52// nuxt.config.ts53export default defineNuxtConfig({54runtimeConfig: {55// Server-only keys56apiSecret: '123',57// Keys within public are exposed to client58public: {59apiBase: '/api',60},61},62})63```6465Override with environment variables:6667```ini68# .env69NUXT_API_SECRET=api_secret_token70NUXT_PUBLIC_API_BASE=https://api.example.com71```7273Access in components/composables:7475```vue76<script setup lang="ts">77const config = useRuntimeConfig()78// Server: config.apiSecret, config.public.apiBase79// Client: config.public.apiBase only80</script>81```8283## App Config8485For public tokens determined at build time (not overridable via env vars):8687```ts88// app/app.config.ts89export default defineAppConfig({90title: 'Hello Nuxt',91theme: {92dark: true,93colors: {94primary: '#ff0000',95},96},97})98```99100Access in components:101102```vue103<script setup lang="ts">104const appConfig = useAppConfig()105</script>106```107108## runtimeConfig vs app.config109110| Feature | runtimeConfig | app.config |111|---------|--------------|------------|112| Client-side | Hydrated | Bundled |113| Environment variables | Yes | No |114| Reactive | Yes | Yes |115| Hot module replacement | No | Yes |116| Non-primitive JS types | No | Yes |117118**Use runtimeConfig** for secrets and values that change per environment.119**Use app.config** for public tokens, theme settings, and non-sensitive config.120121## External Tool Configuration122123Nuxt uses `nuxt.config.ts` as single source of truth. Configure external tools within it:124125```ts126export default defineNuxtConfig({127// Nitro configuration128nitro: {129// nitro options130},131// Vite configuration132vite: {133// vite options134vue: {135// @vitejs/plugin-vue options136},137},138// PostCSS configuration139postcss: {140// postcss options141},142})143```144145## Vue Configuration146147Enable Vue experimental features:148149```ts150export default defineNuxtConfig({151vue: {152propsDestructure: true,153},154})155```156157<!--158Source references:159- https://nuxt.com/docs/getting-started/configuration160- https://nuxt.com/docs/guide/going-further/runtime-config161- https://nuxt.com/docs/api/nuxt-config162-->163