Publish a doc.
Get a short link.
hostdoc uploads a local HTML file or folder to your own AWS and returns a short, shareable link — no platform account, no data leaving your cloud.
Three hosting modes, one upload path
hostdoc has three hosting modes that share one upload path. You pick a mode by how you configure it — the mode is derived, never stored.
Prerequisites & install
- Node.js ≥ 22.12 — check with
node --version. - For the two cloud modes: an AWS account with credentials available to the AWS SDK (see AWS credentials).
- For domain mode only: Terraform installed and a Route53 hosted zone.
- For self-hosted mode: your own Caddy or nginx (or use
--installto auto-install Caddy) — no AWS needed.
AWS credentials
hostdoc never stores AWS keys. It uses the AWS SDK default credential chain (environment variables → SSO → shared ~/.aws profile). Pick a profile with --profile <name> and a region with --region <region>. Use any one of the three setups below.
publisher_policy_json output (and can create the user with create_publisher_user = true).Quick start (S3 website)
This mode serves content publicly over HTTP from an S3 static-website bucket (S3 website endpoints do not support HTTPS). For HTTPS, see Domain mode.
--dry-run prints the URL it would publish to without uploading — and without any AWS call, so it works offline. open builds and opens the URL without checking the document exists. rm asks for confirmation; pass --yes to skip it (required when stdin is not a TTY).Domain mode (CloudFront)
Domain mode serves your docs over HTTPS from a fully private S3 bucket fronted by CloudFront (OAC). It is provisioned with Terraform — no repo checkout needed: the templates ship inside the npm package and are extracted for you into $XDG_STATE_HOME/hostdoc/infra (i.e. ~/.local/state/hostdoc/infra).
Prerequisites: a Route53 hosted zone for your domain, AWS credentials, and Terraform installed.
The single local terraform.tfstate lives in that per-user dir, so it is reused no matter where you run hostdoc from, and deprovision always finds it. Override the location with --dir. Re-running provision never clobbers a dir you have already edited. --price-class overrides the default PriceClass_100.
Already provisioned the infra yourself? Import it without applying: hostdoc init --from-terraform <dir>. Tear it all down with hostdoc deprovision (reuses the saved terraform.tfvars.json; add --approve for non-interactive). Overwriting (--force) and hostdoc rm automatically invalidate /<code>/* on the distribution.
External (non-Route53) DNS
Self-hosted mode (your own NAS/PC)
Self-hosted mode publishes to a local directory served by your own web server — no AWS at all. hostdoc copies files into <serve-root>/<code>/ and returns a link on your own host.
--host is your public host (a DDNS name, domain, or static IP). Add --port for a non-standard port and --scheme https if your server terminates TLS. --nginx emits an nginx server block instead of a Caddyfile (nginx is also auto-selected when it is on PATH); --caddy forces a Caddyfile.
Auto-install (Caddy only)
Add --install and hostdoc downloads Caddy and registers a boot service (Linux/macOS/Windows) so it survives reboot:
Non-privileged prep (config, Caddyfile, binary) runs as your user; the privileged service step runs automatically when you are root/admin, otherwise hostdoc prints the exact sudo (or elevated PowerShell) commands to finish. An --nginx choice falls back to the manual snippet — nginx is not a single static binary. Tear it down with hostdoc deprovision (stops and unregisters the service; published files and the Caddy binary are left in place).
/_* (hostdoc's _meta sidecars) is blocked. Port-forwarding, firewall, and router configuration are up to you; expose only what you intend.Configuration & precedence
Settings resolve in this order — earlier wins. This lets you point hostdoc at bring-your-own infrastructure.
Inspect the saved config with hostdoc config.
Troubleshooting
Use with an agent (skill)
hostdoc ships an installable agent skill so coding agents can drive it conversationally — “publish this folder”, “list my docs”, “remove that slug” — without memorizing flags.
The skill shells out to the hostdoc CLI (preferring a global install, falling back to npx -y hostdoc), so no global install is required. It runs an AWS-free preflight and turns missing config/credentials into guidance instead of raw errors.