Neon is expanding into a backend: Object Storage, Functions, and AI Gateway now in beta
/APIs & SDKs/Setup and context/env

Neon CLI command: env

Manage a branch's Neon environment variables locally

The env command manages a branch's Neon environment variables locally. neon link and neon checkout pull env variables automatically by default.

Subcommands: pull

neon env pull

Writes the branch's Neon environment variables to a local .env file.

neon env pull works with or without a neon.ts configuration file. Without one, it writes the branch's core variables (DATABASE_URL, DATABASE_URL_UNPOOLED, NEON_BRANCH). With a neon.ts, it also writes credentials for each service you declare (Managed Better Auth, Data API, AI Gateway, Object Storage).

neon env pull [options]
OptionDescriptionTypeDefaultRequired
--fileTarget .env file to write. Defaults to an existing .env, otherwise .env.local. Only Neon variables are updated; other lines are preserved.stringNo
--branchBranch ID or namestringNo
--project-idProject IDstringNo

Write the linked branch's Neon variables into .env.local (or .env if present):

neon env pull

Pull a specific branch into a specific file:

neon env pull --branch preview --file .env.preview
Was this page helpful?
Edit on GitHub

On this page

Copy neon init command