supabase functions serve loads per-function env files
Introduced 2026-08-18 · score 0.95
HOW TO USE IT
When serving functions locally with the Supabase CLI v2.115.0, put each function’s values in `supabase/functions/<slug>/.env` and shared values in `supabase/functions/.env`. Run `supabase functions serve`; pass `--env-file <path>` to use that file instead of automatic discovery.
supabase functions servesupabase functions serve --env-file <path>WHY THIS HELPS
Serve functions locally with environment values specific to each function.
BEFORE THIS CHANGE
Before per-function discovery, the Go CLI read only the shared env fallback; the per-function discovery change is documented as TS-only.
REQUIREMENTS AND LIMITATIONS
- Version: v2.115.0
- --env-file <path>: Path to an env file populated into the Function environment; when explicit, it takes precedence and disables automatic reads.
- supabase/functions/.env: Shared local Edge Function secrets file; loaded when the local stack starts.
- supabase/functions/<slug>/.env: Per-function env file; overrides matching shared-file values for that function only.
- Prerequisite: Use CLI v2.115.0 or later for per-function env discovery.
- Prerequisite: Create the env files with the values needed by the functions; the Supabase docs advise adding env files to `.gitignore`.
- Per-function and shared env files are discovered by standalone `supabase functions serve`.
- `supabase start` does not load these files.
FIRST-PARTY EVIDENCE
- https://github.com/supabase/cli/releases/tag/v2.115.0
- https://github.com/supabase/cli/blob/v2.115.0/apps/cli/docs/go-cli-divergences.md
- https://github.com/supabase/cli/blob/v2.115.0/apps/cli/docs/go-cli-reference.md
- https://github.com/supabase/supabase/blob/master/apps/docs/content/guides/functions/secrets.mdx
Check the installed version and the source before using it. Entry JSON