@zerodeploy/cli
v0.1.2
Published
Zero-friction deployment CLI for frontend SPAs
Readme
ZeroDeploy CLI
Command-line interface for deploying static sites and SPAs to ZeroDeploy.
Installation
npm install -g @zerodeploy/cliOr use directly with npx:
npx @zerodeploy/cli deployQuick Start
# 1. Login with GitHub
zerodeploy login
# 2. Create an organization
zerodeploy org create "My Company"
# 3. Create a site
zerodeploy site create my-company "My Website" --subdomain my-website
# 4. Deploy your site
zerodeploy deploy my-website --org my-company --dir ./distYour site will be live at https://my-website.zerodeploy.app
Commands
Authentication
zerodeploy login
Authenticate with GitHub OAuth. Opens your browser for authentication.
zerodeploy loginzerodeploy logout
Clear stored authentication token.
zerodeploy logoutzerodeploy whoami
Display current logged-in user information.
zerodeploy whoamiOrganizations
zerodeploy org list
List all organizations you have access to.
zerodeploy org listzerodeploy org create <name>
Create a new organization.
zerodeploy org create "My Company"zerodeploy org delete <orgSlug>
Delete an organization (must have no sites).
zerodeploy org delete my-companySites
zerodeploy site list <orgSlug>
List all sites in an organization.
zerodeploy site list my-companyzerodeploy site create <orgSlug> <name> --subdomain <subdomain>
Create a new site in an organization.
Options:
--subdomain <subdomain>- Subdomain for the site (required, globally unique)--repo <owner/repo>- Link to a GitHub repository
# Create a site
zerodeploy site create my-company "My Website" --subdomain my-website
# Create a site linked to a GitHub repo
zerodeploy site create my-company "Dashboard" --subdomain dashboard --repo company/monorepoYour site will be available at https://<subdomain>.zerodeploy.app
zerodeploy site delete <siteSlug> --org <orgSlug>
Delete a site and all its deployments.
zerodeploy site delete my-website --org my-companyDeployment
zerodeploy deploy <siteSlug> [options]
Deploy a directory to a site.
Options:
--org <orgSlug>- Organization slug (required)--dir <directory>- Directory to deploy (default: auto-detect)--build- Run build command before deploying--build-command <cmd>- Custom build command--install- Run install command before building
# Deploy specific directory
zerodeploy deploy my-website --org my-company --dir ./dist
# Auto-detect build directory
zerodeploy deploy my-website --org my-company
# Build and deploy
zerodeploy deploy my-website --org my-company --build
# Install dependencies, build, and deploy
zerodeploy deploy my-website --org my-company --install --buildOutput:
Deploying: ./dist
Found 42 files (1.2 MB)
Uploading files...
[100%] 42/42 files
Deployment successful!
URL: https://my-website.zerodeploy.app
Preview: https://019b1234-my-website.zerodeploy.appzerodeploy deployments list <siteSlug> --org <orgSlug>
List deployment history for a site.
zerodeploy deployments list my-website --org my-companyOptions:
--limit <number>- Number of deployments to show (default: 10)
zerodeploy rollback <siteSlug> --org <orgSlug>
Rollback to a previous deployment.
# Rollback to the previous deployment
zerodeploy rollback my-website --org my-company
# Rollback to a specific deployment
zerodeploy rollback my-website --org my-company --to 019b1230Deploy Tokens
Deploy tokens allow CI/CD systems to authenticate without using your personal credentials.
zerodeploy token create <name> --org <org> --site <site>
Create a deploy token for CI/CD.
zerodeploy token create "GitHub Actions" --org my-company --site my-websiteSave the token securely - it will only be shown once.
zerodeploy token list --org <org> --site <site>
List deploy tokens for a site.
zerodeploy token list --org my-company --site my-websitezerodeploy token delete <tokenId> --org <org> --site <site>
Delete a deploy token.
zerodeploy token delete 019b1234 --org my-company --site my-websiteCustom Domains
Connect your own domain to any ZeroDeploy site with automatic SSL.
zerodeploy domain add <domain> --org <org> --site <site>
Add a custom domain to a site. Returns DNS verification instructions.
zerodeploy domain add www.example.com --org my-company --site my-websitezerodeploy domain verify <domain> --org <org> --site <site>
Verify domain ownership after adding the TXT record to your DNS.
zerodeploy domain verify www.example.com --org my-company --site my-websitezerodeploy domain list --org <org> --site <site>
List all custom domains for a site.
zerodeploy domain list --org my-company --site my-websitezerodeploy domain remove <domain> --org <org> --site <site>
Remove a custom domain from a site.
zerodeploy domain remove www.example.com --org my-company --site my-websitezerodeploy domain redirect <domain> --org <org> --site <site> --mode <mode>
Set redirect mode for a custom domain. This allows automatic redirects between www and apex (non-www) domains.
Options:
--mode <mode>- Redirect mode:none,www_to_apex, orapex_to_www
# Redirect www.example.com to example.com
zerodeploy domain redirect example.com --org my-company --site my-website --mode www_to_apex
# Redirect example.com to www.example.com
zerodeploy domain redirect www.example.com --org my-company --site my-website --mode apex_to_www
# Disable redirects
zerodeploy domain redirect example.com --org my-company --site my-website --mode noneCustom Domain Setup:
- Add the domain:
zerodeploy domain add www.example.com --org my-org --site my-site - Add the TXT record to your DNS (shown in output)
- Verify ownership:
zerodeploy domain verify www.example.com --org my-org --site my-site - Add the CNAME record to your DNS (shown in output)
- Your site is now live at
https://www.example.com
Configuration File
Create a zerodeploy.json in your project root:
zerodeploy init --org my-company --site my-websiteThis creates:
{
"org": "my-company",
"site": "my-website"
}Then deploy with just:
zerodeploy deployDeployed Sites
URLs
Each site gets a production URL based on its subdomain:
https://<subdomain>.zerodeploy.appPreview URLs
Every deployment also gets a unique preview URL that remains accessible even after new deployments:
https://<deploymentId>-<subdomain>.zerodeploy.appPreview URLs use the first 8 characters of the deployment ID. Useful for:
- Reviewing changes before promoting to production
- Sharing specific versions with stakeholders
- Comparing different deployments
SPA Support
ZeroDeploy automatically handles SPA (Single Page Application) routing:
- Requests without file extensions fall back to
index.html - Works with React Router, Vue Router, and other client-side routers
Caching
Cache headers are set automatically:
- HTML files: Always revalidate for fresh content
- Hashed assets (e.g.,
main.abc123.js): Cached for 1 year - Other assets: Cached for 1 hour with background revalidation
CI/CD Integration
GitHub Actions
1. Create a deploy token:
zerodeploy token create "GitHub Actions" --org my-company --site my-website2. Add the token to your repository secrets as ZERODEPLOY_TOKEN
3. Create .github/workflows/deploy.yml:
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run build
- name: Deploy
env:
ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}
run: npx @zerodeploy/cli deploy my-site --org my-orgPR Preview workflow:
name: PR Preview
on:
pull_request:
jobs:
preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '20'
- run: npm ci
- run: npm run build
- name: Deploy Preview
env:
ZERODEPLOY_TOKEN: ${{ secrets.ZERODEPLOY_TOKEN }}
run: |
npx @zerodeploy/cli deploy my-site \
--org my-org \
--pr ${{ github.event.pull_request.number }} \
--pr-title "${{ github.event.pull_request.title }}" \
--commit ${{ github.sha }} \
--branch ${{ github.head_ref }} \
--github-outputThe --github-output flag exports deployment info as GitHub Actions outputs:
deployment_id- The deployment IDdeployment_url- The production URLpreview_url- The unique preview URL
Other CI/CD Systems
ZeroDeploy works with any CI/CD system. Set the ZERODEPLOY_TOKEN environment variable and run the deploy command:
# Works with npm, yarn, pnpm, or bun
npx @zerodeploy/cli deploy my-site --org my-org
yarn dlx @zerodeploy/cli deploy my-site --org my-org
pnpm dlx @zerodeploy/cli deploy my-site --org my-org
bunx @zerodeploy/cli deploy my-site --org my-orgFramework Auto-Detection
The CLI automatically detects your framework and uses the appropriate build command and output directory:
| Framework | Build Command | Output Dir |
|-----------|---------------|------------|
| Vite | npm run build | dist/ |
| Next.js | npm run build | out/ |
| Create React App | npm run build | build/ |
| Vue CLI | npm run build | dist/ |
| Nuxt | npm run build | dist/ |
| Astro | npm run build | dist/ |
| SvelteKit | npm run build | build/ |
| Gatsby | npm run build | public/ |
| Remix | npm run build | public/build/ |
| Parcel | npm run build | dist/ |
Auto-detected directories (fallback):
If no framework is detected, the CLI looks for: dist/, build/, out/, public/
Ignored files: The following are automatically excluded from deployments:
node_modules/.git/.env,.env.*files- Hidden files starting with
.
Environment Variables
| Variable | Description |
|----------|-------------|
| ZERODEPLOY_TOKEN | Authentication token (for CI/CD) |
| ZERODEPLOY_API_URL | Custom API URL (defaults to production) |
Troubleshooting
"Not logged in"
Run zerodeploy login to authenticate.
"Org not found"
Use the correct org slug (lowercase, hyphenated). Check with zerodeploy org list.
"Site not found"
Use the correct site and org slugs. Check with zerodeploy site list <orgSlug>.
"No build directory found"
Either:
- Specify the directory with
--dir ./path/to/build - Run with
--buildto build first - Ensure your project has a
dist/,build/,out/, orpublic/directory
