The Surge CLI

surge is a command line tool for publishing static web projects. It does one thing exceptionally well—putting a directory on the web—and then gives you everything you need to run it in production: custom domains, SSL, instant rollbacks, DNS, collaborators, and analytics, all without leaving the terminal.

Install

npm install --global surge

Requires Node.js. Once installed, publishing is one word:

surge

Run it in any directory with an index.html and you're on the web. No account setup beforehand—the CLI walks you through creating one on first run. See Getting Started for the full walkthrough.

The command surface

Command What it does
surge <path> <domain> Publish a project to a domain
surge … --preview Publish a preview without touching production
surge list [domain] List your projects, or a project's revisions
surge rollback / rollfore / cutover / discard Move between revisions
surge dns / zone Manage DNS records
surge encrypt / certs / ssl Provision and inspect SSL certificates
surge config <domain> View and change project settings
surge traffic / audience / usage / load Analytics
surge files / audit / bust Diagnostics and cache control
surge invite / revoke Manage collaborators
surge login / logout / whoami / verify / token / plan / nuke Account and plans
surge teardown <domain> Remove a published project

The complete listing with every flag is in the Command Reference—or run surge --help.

Design principles

The prompt is the UI. Anything the CLI needs and doesn't have, it asks for—and every prompt can be pre-empted with an argument or flag, so every workflow scripts cleanly. surge alone is interactive; surge ./dist example.com never asks a question.

Your project is the configuration. The target domain can live in a CNAME file in your project. Files to exclude go in .surgeignore. There's no required config file, no manifest, no project scaffolding.

Deploys are cheap and reversible. Every publish creates a revision with its own permanent preview URL. surge rollback un-ships a bad deploy in seconds.