[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"tools-page-nuxt-environment-variables":3},{"page":4,"related":415,"variants":434},{"path":5,"name":6,"title":7,"description":8,"checkedAt":9,"sources":10,"faq":47,"related":66,"nuxter":70,"body":73,"tool":413,"preset":414},"\u002Ftools\u002Fnuxt-environment-variables","Nuxt environment variables","Nuxt Environment Variables: runtimeConfig to NUXT_","Paste a nuxt.config to get the Nuxt environment variables that override each runtimeConfig key, the type each value arrives as and the names that collide.","2026-10-06",[11,14,17,20,23,26,29,32,35,38,41,44],{"label":12,"url":13},"Nuxt docs, Runtime config","https:\u002F\u002Fnuxt.com\u002Fdocs\u002F4.x\u002Fguide\u002Fgoing-further\u002Fruntime-config",{"label":15,"url":16},"Nuxt docs, .env","https:\u002F\u002Fnuxt.com\u002Fdocs\u002F4.x\u002Fdirectory-structure\u002Fenv",{"label":18,"url":19},"Nuxt docs, Configuration","https:\u002F\u002Fnuxt.com\u002Fdocs\u002F4.x\u002Fgetting-started\u002Fconfiguration",{"label":21,"url":22},"Nuxt docs, nuxt.config app options","https:\u002F\u002Fnuxt.com\u002Fdocs\u002F4.x\u002Fapi\u002Fnuxt-config",{"label":24,"url":25},"Nitro v2 docs, Configuration","https:\u002F\u002Fv2.nitro.build\u002Fguide\u002Fconfiguration",{"label":27,"url":28},"Nitro v2 source, utils.env.ts","https:\u002F\u002Fgithub.com\u002Fnitrojs\u002Fnitro\u002Fblob\u002Fv2\u002Fsrc\u002Fruntime\u002Finternal\u002Futils.env.ts",{"label":30,"url":31},"scule 1.3.0 source","https:\u002F\u002Fgithub.com\u002Funjs\u002Fscule\u002Fblob\u002Fv1.3.0\u002Fsrc\u002Findex.ts",{"label":33,"url":34},"destr 2.0.5 source","https:\u002F\u002Fgithub.com\u002Funjs\u002Fdestr\u002Fblob\u002Fv2.0.5\u002Fsrc\u002Findex.ts",{"label":36,"url":37},"dotenv 17.4.2 source","https:\u002F\u002Fgithub.com\u002Fmotdotla\u002Fdotenv\u002Fblob\u002Fv17.4.2\u002Flib\u002Fmain.js",{"label":39,"url":40},"Cloudflare Workers docs, Environment variables","https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fconfiguration\u002Fenvironment-variables\u002F",{"label":42,"url":43},"Cloudflare Workers docs, Secrets","https:\u002F\u002Fdevelopers.cloudflare.com\u002Fworkers\u002Fconfiguration\u002Fsecrets\u002F",{"label":45,"url":46},"POSIX.1-2024, Environment variables","https:\u002F\u002Fpubs.opengroup.org\u002Fonlinepubs\u002F9799919799\u002Fbasedefs\u002FV1_chap08.html",[48,51,54,57,60,63],{"question":49,"answer":50},"How does Nuxt map runtimeConfig to environment variables?","Nitro joins the path to each key with underscores, runs it through scule's snakeCase, upper-cases the result and puts NUXT_ in front. runtimeConfig.public.apiBase becomes NUXT_PUBLIC_API_BASE and apiSecret becomes NUXT_API_SECRET. A capital after a lowercase letter starts a new word, so baseURL becomes BASE_URL and oauthGitHubClientId becomes OAUTH_GIT_HUB_CLIENT_ID.",{"question":52,"answer":53},"Why is my NUXT_ environment variable not working?","Usually the key is missing from runtimeConfig, and Nitro only overrides keys that exist when the app is built. Next, check the name against the table, since one misplaced underscore and Nitro ignores it without a word. Last, a built server never reads .env, and in server code useRuntimeConfig(event) is the call that applies the variables on each request.",{"question":55,"answer":56},"Do I need the NUXT_PUBLIC_ prefix?","Only for keys under runtimeConfig.public, which is where the PUBLIC part of the name comes from. Those values reach the browser in every page payload, so keep secrets out of them. A server-only key is NUXT_ followed by its own name.",{"question":58,"answer":59},"Why did my environment variable become a number?","Nitro parses every value with destr, so 12345 arrives as a number, true as a boolean and a JSON object as an object. To keep a value a string, put literal double quotes inside it. In a .env file that reads NUXT_MY_VAR='\"12345\"', and the Check a variable box above writes the line for you.",{"question":61,"answer":62},"How do I set Nuxt environment variables on Cloudflare Workers?","Add secrets with npx wrangler secret put and plain settings in the vars block of your Wrangler file. The Worker sees both as environment variables. For wrangler dev, put them in .dev.vars or .env, but not both. Wrangler environments do not inherit vars, so repeat them under each one.",{"question":64,"answer":65},"What is the difference between the NITRO_ and NUXT_ prefixes?","Both override the same keys. Nitro looks for the NITRO_ name first and falls back to NUXT_, the prefix Nuxt configures, so when both are set the NITRO_ one wins. In a Nuxt app, use NUXT_, which is what the Nuxt docs use throughout.",[67,68,69],"secret-key-generator","nuxt-upgrade-checker","cloudflare-cron-generator",{"body":71,"to":72},"Nuxter declares every key it reads in runtimeConfig, down to an empty slot for each price and AI model, so each NUXT_ variable it documents overrides something. Its build refuses plan, AI role and provider ids that scule would collapse onto another key's variable.","\u002Ffeatures",{"type":74,"value":75,"toc":404},"minimark",[76,81,116,196,222,226,236,281,318,322,340,343,361,365,386,390],[77,78,80],"h2",{"id":79},"how-a-key-becomes-a-name","How a key becomes a name",[82,83,84,85,89,90,93,94,97,98,97,101,104,105,108,109,112,113,103],"p",{},"Nitro walks ",[86,87,88],"code",{},"runtimeConfig"," and, for every key, joins the path to it with underscores, runs that through scule's ",[86,91,92],{},"snakeCase",", upper-cases it and adds a prefix. A new word starts at a separator (",[86,95,96],{},"-",", ",[86,99,100],{},"_",[86,102,103],{},"."," or ",[86,106,107],{},"\u002F",") and wherever a lowercase letter meets a capital. A run of capitals stays one word, except that its last capital starts the next word when a lowercase letter follows, so ",[86,110,111],{},"myAPIKey"," becomes ",[86,114,115],{},"MY_API_KEY",[117,118,119,132],"table",{},[120,121,122],"thead",{},[123,124,125,129],"tr",{},[126,127,128],"th",{},"Key",[126,130,131],{},"Variable",[133,134,135,148,160,172,184],"tbody",{},[123,136,137,143],{},[138,139,140],"td",{},[86,141,142],{},"apiSecret",[138,144,145],{},[86,146,147],{},"NUXT_API_SECRET",[123,149,150,155],{},[138,151,152],{},[86,153,154],{},"public.apiBase",[138,156,157],{},[86,158,159],{},"NUXT_PUBLIC_API_BASE",[123,161,162,167],{},[138,163,164],{},[86,165,166],{},"public.baseURL",[138,168,169],{},[86,170,171],{},"NUXT_PUBLIC_BASE_URL",[123,173,174,179],{},[138,175,176],{},[86,177,178],{},"oauthGitHubClientId",[138,180,181],{},[86,182,183],{},"NUXT_OAUTH_GIT_HUB_CLIENT_ID",[123,185,186,191],{},[138,187,188],{},[86,189,190],{},"s3Bucket",[138,192,193],{},[86,194,195],{},"NUXT_S3_BUCKET",[82,197,198,199,97,202,205,206,209,210,213,214,217,218,221],{},"Because separators and case changes count the same, ",[86,200,201],{},"proMax",[86,203,204],{},"pro-max"," and ",[86,207,208],{},"pro_max"," all become ",[86,211,212],{},"PRO_MAX",". Nitro looks each name up on its own, so one variable then sets every key that shares it. Objects have names too: ",[86,215,216],{},"NUXT_PUBLIC"," set to a JSON object merges into the whole ",[86,219,220],{},"public"," block.",[77,223,225],{"id":224},"why-a-variable-is-ignored","Why a variable is ignored",[82,227,228,229,205,232,235],{},"Nitro only overrides keys that exist in the built config. Declare every key you want to set, even as an empty string. Nuxt turns ",[86,230,231],{},"null",[86,233,234],{},"undefined"," into empty strings, so those count as declared.",[237,238,239,243,254,274],"ul",{},[240,241,242],"li",{},"A name that is off by one underscore matches nothing, and Nitro says nothing about it.",[240,244,245,246,249,250,253],{},"A default such as ",[86,247,248],{},"process.env.API_SECRET"," is read once, at build time. At runtime only the ",[86,251,252],{},"NUXT_"," name for that key changes it.",[240,255,256,97,259,205,262,265,266,269,270,273],{},[86,257,258],{},"nuxt dev",[86,260,261],{},"nuxt build",[86,263,264],{},"nuxt generate"," load ",[86,267,268],{},".env",", and ",[86,271,272],{},"nuxt preview"," hands it to the built server for a local check. In production the server never reads it, so set the variables where it runs.",[240,275,276,277,280],{},"In server code, ",[86,278,279],{},"useRuntimeConfig(event)"," applies the variables for each request. Without the event, Nitro hands back the config it worked out when the server first loaded.",[82,282,283,97,286,289,290,293,294,297,298,300,301,97,304,205,307,310,311,314,315,317],{},[86,284,285],{},"app.config.ts",[86,287,288],{},"appConfig"," and most of the ",[86,291,292],{},"app"," block in ",[86,295,296],{},"nuxt.config"," are fixed at build time. Of the ",[86,299,292],{}," options, only ",[86,302,303],{},"baseURL",[86,305,306],{},"buildAssetsDir",[86,308,309],{},"cdnURL"," reach ",[86,312,313],{},"runtimeConfig.app",", and the Nuxt docs advise against changing ",[86,316,306],{}," at runtime.",[77,319,321],{"id":320},"values-arrive-parsed","Values arrive parsed",[82,323,324,325,328,329,332,333,336,337,339],{},"Nitro runs every value through destr before it touches the config, so ",[86,326,327],{},"true"," arrives as a boolean, ",[86,330,331],{},"12345"," as a number and ",[86,334,335],{},"{\"beta\":true}"," as an object. A value wrapped in literal double quotes stays a string with the quotes removed. In a ",[86,338,268],{}," file, put single quotes around those double quotes, because dotenv strips one layer of quotes itself.",[82,341,342],{},"What happens next depends on the key:",[237,344,345,348,351,354],{},[240,346,347],{},"a plain key takes the parsed value, and an empty value sets it to an empty string",[240,349,350],{},"an object key merges a JSON object into itself and is replaced by anything else",[240,352,353],{},"an array is replaced whole",[240,355,356,205,358,360],{},[86,357,231],{},[86,359,234],{}," leave the default in place",[77,362,364],{"id":363},"public-keys-and-nuxts-own-keys","Public keys and Nuxt's own keys",[82,366,367,368,371,372,374,375,377,378,381,382,385],{},"Everything under ",[86,369,370],{},"runtimeConfig.public"," reaches the browser in the page payload, and so does ",[86,373,313],{},", which Nuxt uses itself. The Nuxt docs reserve top-level keys that start with ",[86,376,292],{}," for Nuxt. Nuxt 4.6 added ",[86,379,380],{},"appSecret",", a server-only root secret that modules derive their own secrets from, and you can set it with ",[86,383,384],{},"NUXT_APP_SECRET"," without declaring it.",[77,387,389],{"id":388},"on-cloudflare-workers","On Cloudflare Workers",[82,391,392,393,396,397,399,400,403],{},"The Worker reads ",[86,394,395],{},"vars"," and secrets as environment variables under the same names. Cloudflare hands a ",[86,398,395],{}," value written as a JSON object to ",[86,401,402],{},"process.env"," as its raw JSON text, and destr parses it back, so it merges into an object key. Text values are parsed the same way, so a text var of digits arrives as a number unless it keeps the inner double quotes the Wrangler template writes.",{"title":405,"searchDepth":406,"depth":406,"links":407},"",2,[408,409,410,411,412],{"id":79,"depth":406,"text":80},{"id":224,"depth":406,"text":225},{"id":320,"depth":406,"text":321},{"id":363,"depth":406,"text":364},{"id":388,"depth":406,"text":389},"nuxt-environment-variables",null,[416,422,428],{"path":417,"tool":67,"name":418,"title":419,"description":420,"summary":421,"checkedAt":9},"\u002Ftools\u002Fsecret-key-generator","Secret key generator","Secret Key Generator for .env, JWT and Webhooks","Generate random secret keys in your browser for NUXT_SESSION_PASSWORD, Better Auth, JWT and webhook signing, as hex, base64, base64url or letters and digits.","Secrets for NUXT_SESSION_PASSWORD, Better Auth, JWT and webhooks, as hex, base64 or base64url, with the .env and Wrangler lines.",{"path":423,"tool":68,"name":424,"title":425,"description":426,"summary":427,"checkedAt":9},"\u002Ftools\u002Fnuxt-upgrade-checker","Nuxt upgrade checker","Nuxt 3 to 4 Migration Checker for Modules and Config","Plan a Nuxt 3 to 4 migration. Paste package.json to see which modules declare Nuxt 4 or 5, which nuxt.config options break, and the official checklist.","Paste a package.json to see which modules declare Nuxt 4 or 5, which config options break, and the official checklist.",{"path":429,"tool":69,"name":430,"title":431,"description":432,"summary":433,"checkedAt":9},"\u002Ftools\u002Fcloudflare-cron-generator","Cloudflare cron trigger generator","Cloudflare Cron Triggers Generator and Tester","Build and test Cloudflare Cron Triggers: plain-English meaning, the next runs in UTC and your time zone, and the Wrangler and Nitro scheduledTasks config.","Build a cron trigger, read it in plain English, see its next runs and copy the Wrangler and Nitro config.",[]]