Docs

CLI

npx @anyshare/cli <path>: share a file or folder from your terminal and get the link.

View as Markdown

The anyshare CLI shares a file or folder and prints the link. It needs Node.js 20 or newer and nothing else: run it with npx, or install it once.

npx @anyshare/cli report.html          # run without installing
npm install -g @anyshare/cli           # or install the `anyshare` command

Share#

anyshare report.html
anyshare ./dist
anyshare screenshot.png notes.md       # several paths become one link
  • One file is uploaded as it is.
  • A folder is zipped in memory and becomes a website if it has an index.html, or a file list if it doesn't.
  • Several paths keep their paths relative to their common parent folder, so anyshare dist/index.html dist/assets/app.js works.

The link is the only thing printed to stdout; progress goes to stderr. That makes it easy to use in scripts:

URL=$(anyshare ./dist -q)

You don't need an account to share, but a link published without one expires after 1 hour unless you keep it. The CLI prints a claim link right after the URL:

http://sunny-otter-4821.anyshare.site
Expires in 1 hour unless you keep it. Keep it (sign in or create a free account): https://anyshare.ai/claim/sunny-otter-4821#token=…
Tip: run `anyshare login` once and new links are saved to your account automatically.

Open the claim link, sign in or create a free account, and the link gets the normal free lifetime: 30 days from the upload. You can also keep it from the terminal with anyshare claim <slug>.

To skip this step for good, sign in once:

anyshare login       # opens the browser; sign in or create a free account, approve the code
anyshare whoami      # prints the signed-in email (exit code 1 if not signed in)
anyshare logout      # forget the sign-in on this machine

anyshare login shows a code such as WDJB-MJHT and opens your browser at the approval page (--no-open just prints the link, for remote shells). Once you approve, the CLI saves an account API key in ~/.config/anyshare/auth.json (readable only by you, mode 0600). From then on every link you publish belongs to your account from the start, with no claim step. In CI or other non-interactive places, set ANYSHARE_API_KEY instead.

anyshare claim <slug> keeps a link published earlier from this machine. When you're signed in it saves the link to your account right away and prints the new expiry; otherwise it prints the claim link and opens it in your browser. anyshare list marks links that still need keeping (unclaimed · expires in 42 minutes).

Options#

OptionWhat it does
--slug <name>Choose the subdomain: --slug q3-report → https://q3-report.anyshare.site
--title <text>Title for the viewer and link previews
--spaSingle-page app: serve index.html for unknown paths
--jsonPrint the full JSON response, including the update token
-q, --quietPrint only the URL, no status lines
-c, --copyCopy the URL to the clipboard
-o, --openOpen the URL in your browser
--no-openFor login and claim: print the link instead of opening the browser

What gets uploaded#

When you share a folder, the CLI never uploads:

  • dependencies, version control and caches: node_modules, .git, .next, .turbo, .cache, __pycache__, .venv and similar
  • OS junk: .DS_Store, Thumbs.db, ._*
  • secrets: .env and .env.*, .dev.vars, .npmrc, .netrc, SSH keys (id_rsa, id_ed25519), *.pem, *.key, .ssh/, .aws/ and similar

Skipped secrets are listed in a warning. If you name a secret file directly (anyshare .env), the CLI refuses.

If a folder has a package.json but no index.html, it is probably source code that hasn't been built. anyshare never runs your build, so the CLI warns and points at the build folder when it finds one:

warning: . looks like project source (package.json, no index.html). anyshare hosts static files
and never runs your build. Did you mean: anyshare ./dist

Free uploads are limited to 50 MB and 1,000 files; the CLI checks this before uploading anything.

Update, delete, list, claim#

Every link you publish is saved, with its update token, in ~/.config/anyshare/sites.json (readable only by you, mode 0600). That's what lets you change a link later without handling tokens:

anyshare update sunny-otter-4821 ./dist    # new content, same URL
anyshare delete sunny-otter-4821
anyshare list                              # links published from this machine
anyshare open sunny-otter-4821             # open in the browser
anyshare claim sunny-otter-4821            # keep it: save it to your account

To update a link published from another machine, pass its token with --token or the ANYSHARE_TOKEN environment variable.

Use it from an agent#

anyshare mcp starts a local MCP server on stdio for Claude Code, Codex, Cursor and other agents. It reads files from disk, so the agent can share a folder in one step:

claude mcp add --scope user anyshare -- npx -y @anyshare/cli mcp

Agents can also call the CLI directly. Use npx -y so npx doesn't stop to ask before installing:

npx -y @anyshare/cli ./dist

Links an agent publishes follow the same 1-hour rule: the agent shows you the claim link next to the URL. Run npx -y @anyshare/cli login once on the machine and the agent's links are saved to your account too.

Environment#

VariableMeaning
ANYSHARE_API_URLUse another server, e.g. http://localhost:3400 in development
ANYSHARE_TOKENToken for update, delete and claim
ANYSHARE_API_KEYAccount API key (as_key_…): publish into your account without anyshare login, e.g. in CI
ANYSHARE_CONFIG_DIRWhere sites.json and auth.json live (default ~/.config/anyshare, or $XDG_CONFIG_HOME/anyshare)

Exit codes and retries#

The CLI exits with 0 on success, 1 for API or network errors and 2 for usage errors such as a missing file. It retries network failures and 429/5xx responses with backoff, sending the same Idempotency-Key each time so a retry never creates a second link. Error messages come from the API and say what to do next.