# Getting online (lesson 2)

The smallest app that can go on a home screen. Use this layout unless the user already has one.

```
my-app/
  wrangler.jsonc
  public/
    index.html
    manifest.webmanifest
    icon.svg
```

`wrangler.jsonc`:

```jsonc
{
  "name": "my-app",
  "compatibility_date": "2026-11-01",
  "assets": { "directory": "./public" }
}
```

- `name` becomes part of the address: `my-app.<their-subdomain>.workers.dev`.
- Use today's date for `compatibility_date` when creating a new app.

`index.html` needs, in `<head>`:

```html
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<link rel="manifest" href="/manifest.webmanifest">
<meta name="theme-color" content="#2f6b4f">
```

`manifest.webmanifest`:

```json
{ "name": "My app", "short_name": "My app", "start_url": "/", "display": "standalone",
  "background_color": "#ffffff", "theme_color": "#2f6b4f",
  "icons": [{ "src": "/icon.svg", "sizes": "any", "type": "image/svg+xml" }] }
```

For iPhone home screens, also add a 180×180 `apple-touch-icon.png`. Render it from the SVG in a browser: some image tools drop SVG arcs.

## Commands

| User says | You run |
|---|---|
| "Log me in to Cloudflare" | `npx wrangler login` (they click Allow) |
| "Let me try it" | `npx wrangler dev`, then open the local address |
| "Put it live" (after you've asked) | `npx wrangler deploy` |

## Snags
- `npx: command not found`: install Node.js (LTS) for them.
- The browser didn't open on login: give them the link from the terminal.
- First deploy asks for a workers.dev subdomain: suggest something short, like their name.
- "Address already in use": run dev on another port (`--port 8788`).
- A new address says "not found": wait a minute, then refresh.
