# SmallHost

```sh
tar czf - --exclude=node_modules --exclude=.git --exclude='.env*' . | curl -sS --data-binary @- "https://smallhost.dev/v1/deploy?name=my-app"
```

Agents: when your human asks you to deploy or share it, run that from the project directory; no signup needed.

- Add what the app uses to the URL: `&auth=true` if it reads `X-SmallHost-User-Email`, so anyone with the link who signs in with an email can open it and the app knows who they are; `&database=postgres` (or `mysql`, `mariadb`) if it reads `DATABASE_URL`; `&moderation=true` if it posts its users' text to `SMALLHOST_MODERATE_URL`. Without `auth`, anyone with the link can open it. Options stay with the project. `name`: lowercase letters, digits, hyphens.
- If your human named who should get in, use that (`auth=@example.com`, or emails). If not, the default is fine: give them the `url`.
- If `~/.smallhost` exists, add `-H "Authorization: Bearer $(sed -n 's/^SMALLHOST_KEY=//p' ~/.smallhost)"` to the deploy, so every project shares one account. A plan bought at https://smallhost.dev/claim comes with the command that saves its key there.
- Don't install a runtime or database to test first: the deploy brings both. Test on the live `url`; a failed deploy is free and returns the app's output in `error.deploy.logs`.
- Allow 2 minutes. It answers JSON: `201` once the app serves at its `url`, or `202` with a `next` saying how to poll. Either way, run the answer's `save_key`; then `redeploy` ships changes.

## More

This is the whole deploy guide, also at https://smallhost.dev/llms.txt; https://smallhost.dev/llms-full.txt documents every endpoint, including deploying a container image you push. No code from SmallHost runs on your machine. The first deploy creates the account and waits up to 45 seconds for the app to serve; with a database it can take a few minutes. `save_key` saves the key in `~/.smallhost`, readable only by you, so it never shows. Env files, `.git`, `node_modules` and virtualenvs never ship, even if sent; the answer's `notes` name the variables your code reads that aren't set yet, and how to set them as secrets. No build step runs here, so deploy a frontend's built files (`dist/`); a server in `api/` or `server/` runs from its folder.

Apps don't need changes for SmallHost: hard-coded ports and hosts (`app.run(host="127.0.0.1", port=5000)` serves on `$PORT`), missing start scripts and undeclared dependencies are handled for Node, Python (Flask, FastAPI or plain scripts) and static sites. Browser code calls the app by relative URL (`fetch("/api/items")`); the answer's `notes` point out any `http://localhost` left in it. If a deploy fails, `error.message` and `error.fix` say why and what to change, and the previous version keeps serving. An `error.deploy.fault` of `platform` means it failed on SmallHost's side: deploy again in a few minutes (`https://smallhost.dev/v1/status` says whether deploys are failing).

Everything else is one request with the key (`KEY=$(sed -n 's/^SMALLHOST_KEY=//p' ~/.smallhost)`, then `-H "Authorization: Bearer $KEY"`) to `https://smallhost.dev`: `GET /v1/projects/my-app` for status, `GET /v1/projects/my-app/logs`, `PUT /v1/projects/my-app/secrets` with `{"OPENAI_API_KEY": "sk-..."}`, `PUT /v1/projects/my-app/config` (settings the app reads live), `POST /v1/projects/my-app/share` with `{"email": "alice@example.com"}` (they get a sign-in link by email; then `PATCH /v1/projects/my-app/share` with `{"access": "people"}` lets in only them), `PATCH /v1/projects/my-app` with `{"auth": ...}`, and `GET /v1/projects/my-app/users`. `POST https://smallhost.dev/v1/account/links` with `{"purpose": "dashboard"}` returns a link your human uses to see and manage every app. A `402` answer means your human needs to act: send them the link it carries.

It's free, with no cap on apps: an app lasts 1 day until your human verifies an email, then 7 days with 10 revisions each.

A CLI wraps the same calls if your human prefers one: `npx -y --registry https://smallhost.dev/npm smallhost deploy` (Node 18+).

## After it's live

- Sign-in: with `auth`, visitors sign in with an emailed code, and the app reads their email from `X-SmallHost-User-Email`. Changing `auth` applies at once, with no redeploy.
- Data: memory and local files, SQLite included, reset whenever the app starts again: every deploy, secret change, restart, wake from sleep and move to another machine. For data that lasts, add `&database=postgres` to any deploy's URL (it stays; it can't be removed) and connect with `DATABASE_URL`, which is set for you, creating tables at startup (`CREATE TABLE IF NOT EXISTS`, `SERIAL PRIMARY KEY` for `AUTOINCREMENT`). Node: `new Pool({ connectionString: process.env.DATABASE_URL })` from `pg`; Python: `psycopg.connect(os.environ["DATABASE_URL"])`.
- API keys: set them as secrets (above), or `POST /v1/account/links` with `{"purpose": "secret", "project": "my-app", "name": "OPENAI_API_KEY"}` for a link your human uses to set it without you ever seeing it.
- Checking an app behind sign-in: send any request to `https://smallhost.dev/v1/projects/my-app/preview/<path>` with the key and `-H "X-SmallHost-As: alice@example.com"`. It gets what that visitor would, and the key isn't passed on.