# Relay (Cloudflare Worker)

**Already on:** after pairing the page uses KidGuard's shared relay and opens from anywhere (link: search `relay` on the page). Your child's state, location and rules pass through the author's Cloudflare account, and the free quota is shared by everyone. Don't want that: make your own relay as below, or turn the relay off in Settings.

## Make your own relay

A small Cloudflare Worker in your own free Cloudflare account relays commands, state and the live screen. Screen frames stay in the Worker's memory only, never stored. The parent's phone only needs a browser.

Needs: a computer with [Node.js](https://nodejs.org) 18+. The Cloudflare account can be made for free at login.

1. On the computer, run: ``` git clone https://github.com/HoangTran0410/kidguard && cd kidguard scripts/relay.sh # Windows powershell -ExecutionPolicy Bypass -File scripts\relay.ps1 ```
2. The script does 3 steps: installs its tools (about a minute the first time), opens the Cloudflare login in your browser (if you're not logged in), then deploys.
3. A new account may be asked to pick a `workers.dev` subdomain: answer it, it becomes part of the relay address.
4. It prints the address: `Relay ready: https://kidguard.<you>.workers.dev` .
5. At home, open the parent page: search `relay` , the own relay (Cloudflare Worker) part. Paste the address, press **Turn on** .
6. The page shows a remote-control link. Open it on your phone (keep it safe, don't share it), or paste it into the parent app.

- Update: run the script again. Remove it from your account: `scripts/relay.sh --delete` (Windows: `-Delete` ).
- Free plan: 100,000 requests a day, one kid's phone uses about 4,300. Commands usually arrive in a few seconds. Listen around doesn't work through the relay.

## Shared relay

Address `https://kg-relay.99-hoangtran.workers.dev`, on by default. The free daily quota is shared by everyone, so on a rare day it can run out: then use the Telegram bot, Tailscale or your own relay.

## Parent watch (preview)

The watch app lets a parent see time left, answer requests, lock, ring and see the location from the wrist. **There is no ready-to-install version yet.**

- **Amazfit (Zepp OS)** : runs on a real watch. Being prepared for the Zepp App Store. Once it is there: open the Zepp app on your phone, go to the app store, search **KidGuard** .
- **Wear OS, Garmin, Apple Watch** : source code only, not tried on a real watch yet.

Connect it like pairing a TV: open KidGuard on the watch and tap **Connect** to get a 6-digit code. On the parent page search `watch`, enter the code and tap **Connect**. The relay must be on for that kid. The code expires after 10 minutes and the watch shows a new one. To look around before connecting, tap **Try demo** on the watch.