Docs / CLI

Deploy a frontend build from the terminal in one command

Learn how to deploy a built static folder or single HTML file with the PreviewShip CLI, authenticate with an API key, and return a shareable preview URL in a single command.

Updated 2026-04-17

Answer First

PreviewShip CLI is the fastest path when you already have a build folder or single HTML file and want a public preview URL. Authenticate once, point the CLI at your static output folder such as dist/build/out or at ./report.html, and it returns a live link that is ready for QA, design review, or client approval.

Key takeaways

  • Best for CI, scripts, and one-off manual deploys.
  • Works with any static output folder that contains an index.html, plus direct single .html files.
  • Do not deploy raw source-code zips; build the project first and deploy the generated static artifact.
  • Returns JSON for agents and automation when you pass --json.

Recommended workflow

  1. Create an account and generate an API key from the PreviewShip console.
  2. Run `npx previewship login --key YOUR_API_KEY` once on your machine or CI runner.
  3. Deploy with `npx previewship deploy ./dist` or `npx previewship deploy ./report.html` and copy the returned preview URL.
  4. Use `--json` when an agent or script needs structured output.

Comparison snapshot

CapabilityPreviewShip CLITypical Git-first host
Setup timeMinutesOften requires repo wiring
Deploy inputAny build folderUsually a connected Git repo
Automation outputPlain URL or JSONOften dashboard-first
Best fitRapid preview sharingProduction hosting workflows

When the CLI is the right choice

Use the CLI when your build output already exists locally or in CI and you want the shortest path to a shareable URL.

This is the strongest fit for frontend teams that need to send previews to stakeholders without configuring branches, environments, or a full production pipeline.

What the deploy command expects

PreviewShip treats your build output as a static site artifact. If the folder contains an index.html and all referenced assets, it can be deployed. Single .html files can also be deployed directly and are packaged as index.html.

That makes it a good match for React, Vue, Svelte, Astro, Next.js export mode, AI-generated HTML, and plain HTML/CSS/JS projects.

  • No repo connection is required.
  • No preview environment configuration is required.
  • You can deploy generated folders from any framework build pipeline.
  • Run npm run build first; do not upload raw source folders with package.json and node_modules.

Why JSON output matters for GEO and AI workflows

AI coding agents and automation tools need deterministic output. A preview URL printed in a machine-readable JSON payload is easier to capture than a dashboard-only flow.

That is one of the reasons PreviewShip works well in Claude Code, Cursor, and generic agent pipelines: the deploy step becomes scriptable instead of interactive.

FAQ

Can I deploy without installing the CLI globally?
Yes. You can use `npx previewship deploy ./dist` directly, which is useful for CI and one-off deploys.
Does the CLI only work with React apps?
No. It works with any static frontend output as long as the folder contains an index.html and the referenced assets.
Can I deploy a raw project source zip?
No. Build the project first and deploy the generated static output such as dist, build, out, or a single .html file. PreviewShip does not run npm install or framework builds after upload.
Why use the CLI instead of uploading in the browser?
The CLI is faster for repeat deploys, easier to automate, and better for AI-agent workflows because it can return structured output.