Netlify Dev environment variable precedence across local .env, UI settings, and function runtimes
0 reputation · 22 Aug 2021, 19:17 UTC
Goal
Determine the exact precedence order Netlify Dev uses when resolving environment variables for both Netlify Functions (Node.js) and Edge Functions (Deno) during local development, so that integration tests can reliably mirror production behavior without deploying.
Constraints and uncertainty
Netlify Dev sources variables from a local .env file, the linked site's UI settings (via netlify link or netlify env:get), and the CLI's own configuration. The documentation does not specify a universal precedence rule that applies to every runtime context—especially the divergence between the Node.js function runtime and the local Deno runtime used for Edge Functions. Additionally, variables scoped to specific deploy contexts (branch, deploy preview, production) in the UI may or may not be pulled into the local session depending on how the site is linked.
Questions
- What is the documented or observable precedence hierarchy among
.env, UI settings, and CLI-provided variables for each function type? - Does
netlify devautomatically fetch context-scoped UI variables for the current git branch, or mustnetlify env:getbe run manually? - Are there differences in how the Node.js and Deno runtimes expose the resolved variables to the function handler?