Netlify CLI And Deploy
Guide for using the Netlify CLI and deploying sites. Use when installing the CLI, linking sites, deploying (Git-based or manual), managing
What Is This?
Overview
Netlify CLI is a command-line interface tool that allows developers to interact with the Netlify platform directly from their terminal. It provides a complete workflow for deploying static sites, serverless functions, and full-stack web applications without requiring a browser-based dashboard for every operation. The CLI bridges local development environments with Netlify's hosting infrastructure, making it possible to automate deployments, manage configuration, and test production-like behavior locally.
The tool supports two primary deployment workflows: Git-based continuous deployment and manual file uploads. Git-based deployments connect a repository to Netlify so that every push triggers an automatic build and deploy cycle. Manual deployments, on the other hand, allow developers to push specific build output directories directly to Netlify on demand, which is useful for custom pipelines or non-standard project structures.
Beyond deployment, Netlify CLI includes a local development server through the netlify dev command. This server replicates the Netlify environment on your machine, including environment variables, redirect rules, and serverless function execution, so you can test your application accurately before pushing to production.
Who Should Use This
- Frontend developers building static sites or JAMstack applications who want faster deployment workflows
- DevOps engineers setting up CI/CD pipelines that require automated Netlify deployments
- Full-stack developers who need to test serverless functions locally before deploying
- Teams managing multiple Netlify sites who want to script and automate site management tasks
- Developers working on projects without a Git repository who need manual deployment options
- Engineers who need to manage environment variables programmatically across different deployment contexts
Why Use It?
Problems It Solves
- Eliminates the need to navigate the Netlify dashboard for routine deployment and configuration tasks
- Removes the gap between local development and production behavior by replicating the Netlify environment locally
- Enables automated deployments in CI/CD pipelines where browser-based workflows are not practical
- Simplifies environment variable management across development, staging, and production contexts
- Allows teams to deploy specific build artifacts without requiring a full Git integration
Core Highlights
- Global or local installation options to suit both developer workstations and CI environments
netlify devcommand for local server with full Netlify feature parity- Support for both Git-linked and manual deployment workflows
- Environment variable injection and management via CLI commands
- Site linking to connect local projects to existing Netlify sites
- Deploy previews for testing changes before merging to production branches
- Serverless function testing in the local development environment
- Authentication via personal access tokens for secure CI/CD integration
How to Use It?
Basic Usage
Install the CLI globally for local development or as a dev dependency for CI environments:
npm install -g netlify-cli # Global installation for local development
npm install netlify-cli -D # Local installation for CI pipelinesAuthenticate and link your project to a Netlify site:
netlify login # Opens browser for OAuth authentication
netlify link # Links current directory to a Netlify site
netlify status # Confirms linked site and account detailsSpecific Scenarios
Scenario 1: Manual deployment of a build directory
After running your build process, deploy the output folder directly:
npm run build
netlify deploy --dir=dist --prodOmitting --prod creates a draft deploy URL for review before promoting to production.
Scenario 2: Local development with serverless functions
Start the local development server to test functions and redirects:
netlify devThis command reads your netlify.toml configuration, injects environment variables, and serves your application at http://localhost:8888.
Real-World Examples
A team running a React application can connect their GitHub repository through netlify link, then use netlify deploy --build to trigger a production build and deploy in a single command. For a CI pipeline using GitHub Actions, the CLI can be installed locally and authenticated with a NETLIFY_AUTH_TOKEN secret, then used to deploy on every merge to the main branch.
When to Use It?
Use Cases
- Deploying static sites built with frameworks like Next.js, Gatsby, or Astro
- Running local development servers that accurately reflect the production Netlify environment
- Automating deployments in GitHub Actions, GitLab CI, or other pipeline tools
- Managing environment variables across multiple deployment contexts from the terminal
- Creating deploy previews for feature branches without full Git integration
- Testing serverless functions locally before committing changes
- Linking multiple local project directories to their corresponding Netlify sites
Important Notes
Requirements
- Node.js version 14 or higher must be installed on the target machine
- A Netlify account is required for authentication and site management
- For CI deployments, a
NETLIFY_AUTH_TOKENpersonal access token must be generated from the Netlify dashboard
More Skills You Might Like
Explore similar skills to enhance your workflow
dbt Transformation Patterns
Production-ready patterns for dbt (data build tool) including model organization, testing strategies, documentation, and incremental processing
Chro Advisor
People leadership for scaling companies. Hiring strategy, compensation design, org structure, culture, and retention. Use when building hiring plans,
Voltagent Docs Bundle
Look up VoltAgent documentation embedded in node_modules/@voltagent/core/docs for version-matched docs. Use for API signatures, guides, and examples
Create GitHub Issues For Unmet Specification Requirements
create-github-issues-for-unmet-specification-requirements skill for design & creative
Brand Guidelines
When the user wants to apply, document, or enforce brand guidelines for any product or company. Also use when the user mentions 'brand guidelines,' 'b
Auth Patterns
This skill should be used when the user asks about "authentication in Next.js", "NextAuth", "Auth.js", "middleware auth", "protected routes", "session