Skip to main content

Convex CLI

The Convex command-line interface (CLI) is your interface for managing Convex deployments and Convex functions.

To install the CLI, run:

npm install convex

You can view the full list of commands with:

npx convex -h

A cheat sheet of commands is available in the Quick Start Guide.

Manage Deployments

All of these commands require logging in first with:

npx convex login

Create a new deployment

npx convex init

Create a new deployment for the current project. This command creates:

  1. The convex/ directory: This is the home for your query and mutation functions.
  2. convex.json: This is the main configuration for your Convex deployment. It includes a randomly assigned deployment URL.
  3. .env.local: This contains an admin key that authorizes your to manage your deployment.

Deactivate a deployment

npx convex deactivate

This command will stop the running deployment, and its data will no longer be accessible. Deactivating a deployment will give you back a credit that you can use to provision a new deployment with npx convex init.

Recreate deployment configuration files

npx convex reinit --deployment-name <name>

Recreate the convex.json and .env.local files if you lose them. You can find the deployment name by viewing the dashboard.

Write Code

Push Convex functions

npx convex push

This command will:

  1. Typecheck your Convex functions.
  2. Regenerate the generated code.
  3. Bundle your Convex functions and their dependencies.
  4. Push your functions to your Convex deployment.

Once this command succeeds the new functions will be available immediately. You should run this command anytime you create or modify your Convex functions.

Update generated code

npx convex codegen

Update the generated code in convex/_generated without pushing. This is useful after adding or removing Convex functions or making schema changes.

Typecheck functions

npx convex typecheck

Run TypeScript over all of your functions without pushing.

Modify authentication settings

npx convex auth <subcommand>

Update the authentication settings for your application. The possible subcommands are:

  • add
  • remove
  • list

To learn more about adding authentication to your app, see the Users and Auth Tutorial.


Open the dashboard

npx convex dashboard

Open the Convex dashboard.

Open the docs

npx convex docs

Open these docs!