Documentation
Complete reference for the Leash CLI. Learn how to deploy, manage databases, and configure your applications.
Getting Started
Install the Leash CLI globally using npm:
npm install -g @leash/cli# Login to your account leash login # Navigate to your project cd my-nextjs-app # Deploy your app leash deploy # Your app is live at: # https://leash.build/username/my-nextjs-app
Authentication
leash register
Create a new Leash account. You'll be prompted for your name, username, email, and password.
Usage:
leash registerExample:
$ leash register
? Name: John Doe
? Username: johndoe
? Email: john@example.com
? Password: ********
Successfully registered! Welcome to Leash.leash login
Authenticate with your Leash account. Your credentials are stored securely.
Usage:
leash loginExample:
$ leash login
? Email: john@example.com
? Password: ********
Logged in successfully!leash logout
Log out from your Leash account and remove stored credentials.
Usage:
leash logoutleash whoami
Display information about the currently authenticated user.
Usage:
leash whoamiExample:
$ leash whoami
Username: johndoe
Email: john@example.com
Name: John DoeApp Management
leash init
Initialize a new Leash app in the current directory. Creates a .leash/config.json file.
Usage:
leash init [options]Options:
| -n, --name <name> | App name (optional, prompts if not provided) |
Example:
$ leash init --name my-app
App "my-app" initialized!
App ID: abc123
URL: https://leash.build/johndoe/my-appleash apps:list
List all your deployed apps.
Usage:
leash apps:listExample:
$ leash apps:list
ID NAME URL CREATED
abc123 my-app leash.build/johndoe/my-app 2024-01-15
def456 portfolio leash.build/johndoe/portfolio 2024-01-10leash apps:delete
Delete an app and all associated resources.
Usage:
leash apps:delete <appId>Example:
$ leash apps:delete abc123
? Are you sure you want to delete my-app? Yes
App deleted successfully.Deployment
leash deploy
Deploy the current app to Leash. Auto-detects your framework (Next.js, Expo, Vite) and configures the deployment automatically. If no app is initialized, it will create one using the directory name.
Usage:
leash deploy [options]Options:
| -m, --message <message> | Deployment message (optional) |
Example:
$ leash deploy
Analyzing project...
Detected Next.js 15 with App Router
Running pre-flight checks...
✓ Lint passed
✓ Build passed
Deploying to Leash...
✓ Deployed successfully!
→ https://leash.build/johndoe/my-appEnvironment Variables
leash env:set
Set an environment variable for your app. The variable will be available in your next deployment.
Usage:
leash env:set <key> <value> [options]Options:
| -a, --app <appId> | App ID (uses current app if not specified) |
Example:
$ leash env:set DATABASE_URL "postgresql://user:pass@host:5432/db"
Environment variable DATABASE_URL set successfully.leash env:list
List all environment variables for your app.
Usage:
leash env:list [options]Options:
| -a, --app <appId> | App ID (uses current app if not specified) |
Example:
$ leash env:list
KEY VALUE
DATABASE_URL postgresql://...
API_KEY sk-...leash env:delete
Delete an environment variable from your app.
Usage:
leash env:delete <key> [options]Options:
| -a, --app <appId> | App ID (uses current app if not specified) |
Logs
leash logs
View application logs. Use --follow to stream logs in real-time.
Usage:
leash logs [options]Options:
| -a, --app <appId> | App ID (uses current app if not specified) |
| -f, --follow | Stream logs in real-time |
| -n, --lines <number> | Number of lines to show (default: 100) |
Example:
$ leash logs --follow
2024-01-15 10:30:00 [INFO] Server started on port 3000
2024-01-15 10:30:05 [INFO] GET /api/health - 200
2024-01-15 10:30:10 [INFO] POST /api/users - 201Database
leash db:create
Create a managed database. Supports PostgreSQL and MongoDB. If linked to an app, the DATABASE_URL environment variable is automatically set.
Usage:
leash db:create [options]Options:
| -t, --type <type> | Database type (postgres, mongodb) |
| -n, --name <name> | Database name |
| -a, --app <appId> | Link to app (auto-sets DATABASE_URL) |
Example:
$ leash db:create --type postgres --name myapp-db --app abc123
Creating PostgreSQL database...
✓ Database created successfully!
Connection string: postgresql://user:pass@host:5432/myapp-db
DATABASE_URL automatically set for app.leash db:list
List all your databases.
Usage:
leash db:listExample:
$ leash db:list
ID NAME TYPE STATUS HOST CREATED
xyz789 myapp-db postgres active shared-postgres:5432 2024-01-15leash db:delete
Delete a database. This action cannot be undone.
Usage:
leash db:delete <databaseId>Example:
$ leash db:delete xyz789
? This will permanently delete the database. Continue? Yes
Database deleted successfully.leash db:connect
Get connection details for a database.
Usage:
leash db:connect <databaseId>Example:
$ leash db:connect xyz789
Database: myapp-db
Type: PostgreSQL
Host: shared-postgres.cluster.local
Port: 5432
Connection String: postgresql://user:pass@host:5432/myapp-db
Connect with psql:
psql "postgresql://user:pass@host:5432/myapp-db"Configuration
leash config
Show current configuration including API URL and authentication status.
Usage:
leash configExample:
$ leash config
API URL: https://leash.build/api
Authenticated: Yes
User: johndoe (john@example.com)leash config:set-url
Set the API URL. Useful for connecting to different environments.
Usage:
leash config:set-url <url>Example:
$ leash config:set-url https://staging.leash.build/api
API URL set to: https://staging.leash.build/apileash config:get-url
Get the current API URL.
Usage:
leash config:get-urlleash config:reset
Reset configuration to defaults.
Usage:
leash config:reset