or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

authentication-teams.mdblobs-storage.mdbuild-system.mddeployment.mdenvironment-variables.mdfunctions.mdindex.mdlocal-development.mdsite-management.md
tile.json

tessl/npm-netlify-cli

Netlify command line tool for deploying and managing modern web applications on the Netlify platform

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
npmpkg:npm/netlify-cli@23.5.x

To install, run

npx @tessl/cli install tessl/npm-netlify-cli@23.5.0

index.mddocs/

Netlify CLI

Netlify CLI is a command-line interface tool that enables developers to interact with Netlify's platform for modern web development and deployment. It provides comprehensive commands for managing sites, deploying applications, running local development servers, handling serverless functions, managing environment variables, and integrating with Netlify's edge functions and build system.

Package Information

  • Package Name: netlify-cli
  • Package Type: npm
  • Language: TypeScript/JavaScript
  • Installation: npm install -g netlify-cli
  • Node.js Version: >=20.12.2

Core Imports

The CLI provides both command-line binaries and programmatic APIs:

Command-line binaries:

netlify --help
ntl --help  # short alias

Programmatic API (Node.js):

import { NetlifyAPI, methods } from "netlify-cli";

For CommonJS:

const { NetlifyAPI, methods } = require("netlify-cli");

Basic Usage

Quick start:

# Install globally
npm install -g netlify-cli

# Login to Netlify
netlify login

# Initialize a project
netlify init

# Start local development
netlify dev

# Deploy to production
netlify deploy --prod

Common workflow:

# Clone a project with the CLI
netlify clone [repository]

# Link to existing Netlify site
netlify link

# Set environment variables
netlify env:set API_KEY "your-api-key"

# Run local development server with Netlify features
netlify dev --port 3000

# Deploy with build
netlify deploy --build --prod

Architecture

The Netlify CLI is built on several key components:

  • Command System: Built using Commander.js with a base command class and 24 main commands
  • Authentication: OAuth-based login with persistent token storage
  • Local Development: Full dev server with proxy, redirects, and serverless functions
  • Build Integration: Integration with Netlify Build system and local builds
  • API Client: Direct access to Netlify's REST API through programmatic interface
  • Deployment Engine: Handles file uploads, build triggers, and deployment management
  • Environment Management: Context-aware environment variable handling

Capabilities

Site Management

Core project and site management functionality for creating, linking, and configuring Netlify projects.

// Command: netlify sites:create
interface SiteCreateOptions {
  name?: string;           // Project name (max 63 chars)
  accountSlug?: string;    // Account slug
  withCi?: boolean;        // Initialize CI hooks
  manual?: boolean;        // Force manual CI setup
  disableLinking?: boolean; // Create without linking
}

// Command: netlify link
interface LinkOptions {
  id?: string;             // Project ID to link
  name?: string;           // Project name to link
  gitRemoteName?: string;  // Git remote name
}

Site Management

Local Development

Local development server with Netlify's proxy, redirect rules, and serverless function support.

// Command: netlify dev
interface DevOptions {
  command?: string;        // Command to run
  context?: string;        // Deploy context (default: dev)
  port?: number;           // Netlify dev port
  targetPort?: number;     // Target app server port
  framework?: string;      // Framework to use (#auto for detection)
  dir?: string;           // Static files directory
  functions?: string;      // Functions folder
  live?: string | boolean; // Start public live session
  geo?: 'cache' | 'mock' | 'update'; // Geolocation mode
  country?: string;        // Two-letter country code
  offline?: boolean;       // Disable network features
}

Local Development

Deployment

Build and deployment functionality with support for various contexts and deployment options.

// Command: netlify deploy
interface DeployOptions {
  dir?: string;            // Directory to deploy
  functions?: string;      // Functions folder
  prod?: boolean;          // Deploy to production
  prodIfUnlocked?: boolean; // Deploy to production if unlocked
  alias?: string;          // Deployment alias (max 37 chars)
  message?: string;        // Deploy log message
  json?: boolean;          // Output as JSON
  timeout?: number;        // Deployment timeout
  build?: boolean;         // Run build command
  createSite?: string;     // Create new site during deployment
}

Deployment

Environment Variables

Environment variable management with context support for different deployment environments.

// Command: netlify env:set
interface EnvSetOptions {
  context?: string[];      // Deploy contexts (multiple)
  scope?: ('builds' | 'functions' | 'post-processing' | 'runtime' | 'any')[]; // Variable scopes
  secret?: boolean;        // Mark as secret variable
  json?: boolean;          // Output as JSON
}

// Command: netlify env:get
interface EnvGetOptions {
  context?: string;        // Deploy context (default: dev)
  scope?: 'builds' | 'functions' | 'post-processing' | 'runtime' | 'any'; // Variable scope
  json?: boolean;          // Output as JSON
}

Environment Variables

Functions

Serverless function management including creation, testing, and deployment of Netlify Functions.

// Command: netlify functions:create
interface FunctionCreateOptions {
  name?: string;           // Function name
  url?: string;            // Template URL
  language?: string;       // Function language
  offline?: boolean;       // Disable network features
}

// Command: netlify functions:invoke
interface FunctionInvokeOptions {
  name?: string;           // Function name
  functions?: string;      // Functions folder
  querystring?: string;    // Query string
  payload?: string;        // POST payload
  identity?: boolean;      // Simulate Netlify Identity JWT
  noIdentity?: boolean;    // Simulate unauthenticated request
  port?: number;          // Netlify dev port
}

Functions

Blobs Storage

Object storage management for Netlify Blobs with CRUD operations and metadata handling.

// Command: netlify blobs:set
interface BlobSetOptions {
  input?: string;          // Read data from filesystem path
}

// Command: netlify blobs:get
interface BlobGetOptions {
  output?: string;         // Output path to save blob data
}

// Command: netlify blobs:list
interface BlobListOptions {
  directories?: boolean;   // Treat keys with '/' as directories
  prefix?: string;         // Filter entries by prefix
  json?: boolean;          // Output as JSON
}

Blobs Storage

Build System

Local and remote build functionality with context support and offline capabilities.

// Command: netlify build
interface BuildOptions {
  context?: string;        // Deploy context (default: production)
  dry?: boolean;          // Show instructions without running
  offline?: boolean;       // Disable network features
}

// Command: netlify serve
interface ServeOptions {
  context?: string;        // Deploy context
  port?: number;          // Server port
  dir?: string;           // Static files directory
  functions?: string;      // Functions folder
  geo?: 'cache' | 'mock' | 'update'; // Geolocation mode
}

Build System

Authentication & Teams

Authentication management and team switching functionality for multi-account workflows.

// Command: netlify login
interface LoginOptions {
  new?: boolean;           // Login to new account
}

Authentication & Teams

Database Management

PostgreSQL database provisioning and management for modern web applications.

// Command: netlify database:init
interface DatabaseInitOptions {
  assumeNo?: boolean;          // Non-interactive setup
  boilerplate?: 'drizzle';     // Type of boilerplate to add
  noBoilerplate?: boolean;     // Don't add boilerplate code
  overwrite?: boolean;         // Overwrite existing files
}

// Command: netlify database:status
interface DatabaseStatusOptions {
  /** No additional options */
}

Project Cloning

Clone Git repositories with optional framework filtering for quick project setup.

// Command: netlify clone [repository] [directory]
interface CloneOptions {
  filter?: string;             // Filter template results by framework
}

File Watching

Watch for project changes and deploy automatically for continuous deployment workflows.

// Command: netlify watch
interface WatchOptions {
  dir?: string;                // Directory to deploy
  functions?: string;          // Functions folder
}

Log Management

Stream and view logs from builds and serverless functions for debugging and monitoring.

// Command: netlify logs:deploy (alias: logs:build)
interface LogsDeployOptions {
  /** No additional options */
}

// Command: netlify logs:function [functionName]
interface LogsFunctionOptions {
  level?: ('trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal')[]; // Log levels to stream
}

Project Recipes

Interactive setup and configuration templates for different frameworks and use cases.

// Command: netlify recipes
interface RecipesOptions {
  /** Interactive recipe selection */
}

Development Execution

Execute commands in the development environment context with full access to environment variables.

// Command: netlify dev-exec <command...>
interface DevExecOptions {
  context?: string;            // Deploy context for environment variables
}

Resource Opening

Open project resources and admin interfaces in browser for quick access.

// Command: netlify open:admin
interface OpenAdminOptions {
  /** No additional options */
}

// Command: netlify open:site
interface OpenSiteOptions {
  /** No additional options */
}

API Access

Direct access to Netlify's REST API for advanced automation and custom integrations.

// Command: netlify api
interface ApiOptions {
  data?: string;               // JSON data payload for API call
  list?: boolean;              // List all available API methods
}

Shell Completion

Generate shell completion scripts for improved command-line productivity.

// Command: netlify completion
interface CompletionOptions {
  shell?: 'bash' | 'zsh' | 'fish' | 'powershell'; // Target shell
}

Global Options

All commands support these global options:

interface GlobalOptions {
  telemetryDisable?: boolean; // Disable usage telemetry
  telemetryEnable?: boolean;  // Enable usage telemetry
  version?: boolean;          // Show version information
  verbose?: boolean;          // Show detailed environment information
  auth?: string;              // Authentication token
  debug?: boolean;            // Enable debug mode
  cwd?: string;               // Working directory (hidden but functional)
  httpProxy?: string;         // HTTP proxy configuration (hidden)
  silent?: boolean;           // Silence output (hidden)
  filter?: string;            // Monorepo package selection
}

Deploy Contexts

The CLI supports context-aware operations for different deployment environments:

  • production - Production environment
  • deploy-preview - Deploy preview environment (pull requests)
  • branch-deploy - Branch deployment environment
  • dev - Development environment (local)
  • branch:branch-name - Specific branch context

Types

type DeployContext = 'production' | 'deploy-preview' | 'branch-deploy' | 'dev' | `branch:${string}`;

type VariableScope = 'builds' | 'functions' | 'post-processing' | 'runtime' | 'any';

type GeoMode = 'cache' | 'mock' | 'update';

type LogLevel = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';

interface NetlifyConfig {
  build?: {
    command?: string;
    publish?: string;
    functions?: string;
  };
  redirects?: Array<{
    from: string;
    to: string;
    status?: number;
  }>;
  headers?: Array<{
    for: string;
    values: Record<string, string>;
  }>;
}

Programmatic API

The CLI also provides programmatic access to Netlify's API:

/**
 * Netlify API client for programmatic access
 * Re-exported from @netlify/api package
 */
class NetlifyAPI {
  constructor(token?: string, options?: ApiOptions);
  
  // Site management
  listSites(): Promise<Site[]>;
  getSite(siteId: string): Promise<Site>;
  createSite(params: CreateSiteParams): Promise<Site>;
  deleteSite(siteId: string): Promise<void>;
  
  // Deploy management
  listDeploys(siteId: string): Promise<Deploy[]>;
  getDeploy(deployId: string): Promise<Deploy>;
  createDeploy(siteId: string, params: CreateDeployParams): Promise<Deploy>;
  
  // Function management
  listFunctions(siteId: string): Promise<Function[]>;
  // ... additional API methods
}

/**
 * API method definitions
 * Re-exported from @netlify/api package
 */
const methods: {
  listSites: ApiMethod;
  getSite: ApiMethod;
  createSite: ApiMethod;
  // ... additional method definitions
};