Neon CLI quickstart
The Neon CLI lets you manage Neon directly from the terminal. This guide helps you set up and start using it. The CLI is invoked as neon; neonctl is an alias for neon, so commands work with either nam...
The Neon CLI lets you manage Neon directly from the terminal. This guide helps you set up and start using it. The CLI is invoked as neon; neonctl is an alias for neon, so commands work with either name.
Install the CLI
Choose your platform and install the Neon CLI:
Install with Homebrew
Bash brew install neonctlInstall via npm
Bash npm i -g neonInstall with bun
Bash bun install -g neonInstall via npm
Shell npm i -g neonInstall with bun
Bash bun install -g neonInstall via npm
Shell npm i -g neonInstall with bun
Bash bun install -g neonVerify the installation by checking the CLI version:
Bash neon --versionFor the latest version, refer to the Neon CLI GitHub repository.
Authenticate
Authenticate with your Neon account using one of these methods:
Web Authentication (recommended)
Run the command below to authenticate through your browser:
Bash neon loginThis opens a browser window where you can authorize the CLI to access your Neon account.
API Key Authentication
Alternatively, use a personal Neon API key, which you can create in the Neon Console. See Create a personal API key.
Bash neon projects list --api-key <your-api-key>To avoid entering your API key with each command, set it as an environment variable:
Bash export NEON_API_KEY=<your-api-key>For more about authenticating, see Neon CLI commands: login.
Link your project
The easiest way to set up CLI context is with
neon link. It guides you through organization and project selection and writes a.neoncontext file in your project directory.Bash neon linkYou can also link non-interactively for scripts and CI.
linkwrites a complete context, so pin a branch with--branch(or pass-yto pin the project's default branch):Bash neon link --org-id <your-org-id> --project-id <your-project-id> --branch mainEither form of
neon linkcreates a.neonfile in your current directory with your project context.Bash cat .neonJSON { "projectId": "broad-surf-52155946", "orgId": "org-solid-base-83603457", "branch": "main" }Enable shell completion
Set up autocompletion to make using the CLI faster:
Bash neon completion >> ~/.bashrc source ~/.bashrcZsh neon completion >> ~/.zshrc source ~/.zshrcNow you can press Tab to complete Neon CLI commands and options. For further details, see Neon CLI commands: completion.
Common operations
List your projects
Bash neon projects listIf no organization context is set, the CLI prompts you to select an organization.
For more about the
projectscommand, see Neon CLI commands: projects.Create a branch
Bash neon branches create --name <branch-name>Set your project context or specify
--project-id <your-project-id>if you have more than one Neon project.To switch the active branch in your context file, use
neon checkout:Bash neon checkout <branch>For more about the
branchescommand, see Neon CLI commands: branches.Get a connection string
Get the connection string for the default branch in your project:
Bash neon connection-stringFor a specific branch, specify the branch name:
Bash neon connection-string <branch-name>To connect with
psqldirectly, use the dedicatedneon psqlcommand:Bash neon psqlFor more about the
connection-stringcommand, see Neon CLI commands: connection-string.Next steps
Now that you're set up with the Neon CLI, you can:
- Create more Neon projects with
neon projects create - Manage your branches with various
neon branchescommands such asreset,restore,rename,schema-diff, and more - Create and manage databases with
neon databasescommands - Create and manage roles with
neon rolescommands - View the full set of Neon CLI commands available to you with
neon --help
For more details on all available commands, see the CLI Reference.
- Create more Neon projects with