Neon CLI — Install and connect
Use the Neon CLI to manage Neon directly from the terminal
This section describes how to install the Neon CLI and connect via web authentication or API key.
Prerequisites
Before installing, ensure that you have met the following prerequisites:
-
Node.js 16.0 or higher. To check if you already have Node.js, run the following command:
-
The
npm
package manager. To check if you already havenpm
, run the following command:If you need to install
Node.js
ornpm
, refer to instructions on the official nodejs page or use the Node version manager.
Install
To install the Neon CLI, run the following command:
Homebrew is also supported:
Upgrade
To upgrade to the latest version of the Neon CLI, run the npm i -g neonctl
command again.
Connect
The Neon CLI supports connecting via web authentication or API key.
Web authentication
Run the following command to connect to Neon via web authentication:
The neonctl auth command launches a browser window where you can authorize the Neon CLI to access your Neon account. If you have not authenticated previously, running a Neon CLI command automatically launches the web authentication process unless you have specified an API key.
API key
To authenticate with a Neon API key, you can specify the --api-key
option when running a Neon CLI command. For example, the following neonctl projects list
command authenticates to Neon using the --api-key
option:
To avoid including the --api-key
option with each CLI command, you can export your API key to the NEON_API_KEY
environment variable.
For information about obtaining an Neon API key, see Create an API key.
Configure autocompletion
The Neon CLI supports autocompletion, which you can configure in a few easy steps. See Neon CLI commands — completion for instructions.