Chart RS-26 · Field notes FN-01 · 2026-12-04 · 7 min read

Field note FN-01

Running 34 Garmin watch apps on Workers + R2

14 Workers, 3 R2 buckets and a 129 GB planet map behind apps for a device that accepts 16 KB per response.

Since November I’ve published 34 apps, watch faces and data fields for Garmin watches under Silva Dev Labs. They name the mountain you point your wrist at, draw the aircraft overhead, show offline maps and ski pistes, and plot the nearest earthquake’s seismogram.

None of that fits on a watch. Behind them sit 14 Cloudflare Workers, all TypeScript, with 3 R2 buckets, 4 D1 databases and one Durable Object class. This note is about what the watch forces you to do, and why Workers and R2 turned out to be a good shape for it.

The watch is the constraint

A Garmin app talks to the internet through the paired phone, with makeWebRequest, and gets JSON back. Everything else follows from how little the watch can take. These numbers are all from comments in my own code, where each one explains a design decision:

So the server’s job is not “be an API”. It is to do the heavy work and hand the watch something tiny, already shaped for how the watch will use it.

Pack answers for the watch, not for a browser

JSON is the only transport, so everything binary rides inside it as base64: a place in Refill is 14 bytes, a quake in Tremor is 22, and True Sunset’s skyline is a run of int16 angles. Where it has to stay JSON, Skyward uses arrays instead of objects, because the watch parses them in far less memory. The header comment in near.ts is the whole spec:

// Answer (arrays, not objects: a watch parses them in far less memory):
// { "v":1, "t":epoch s, "src":"adsb.lol (ODbL)", "r":km, "c":count in the circle,
//   "ac":[[hex, callsign, lat·1e5, lon·1e5, altFt|null, gsKt|null, track|null, ...], ...],
//   "ty":[[designator, name], ...],
//   "rt":[[flight, airline, fromCode, fromCity, ...], ...] }

Aircraft types and routes are de-duplicated into lookup tables that rows point into. A typical answer is about 3 KB, down from 34 KB raw.

Let nearby users share one upstream call

Live data comes from public sources (adsb.lol for aircraft, USGS and EMSC for earthquakes, Nominatim for place names) that I want to be a polite client of. The trick used across the Workers is to round the user’s position until nearby users produce the same cache key.

Skyward fetches aircraft per 0.2° tile (about 22 km), with a radius that covers any point in the tile, and caches it for four seconds:

export const TILE = 0.2;
const MARGIN_KM = 17;                  // farthest a point can be from its tile's centre, and a little
const BUCKETS_NM = [15, 30, 60, 100];  // upstream radius steps
const POS_TTL = 4;                     // seconds

Each answer is then cut down to the user’s own circle and sorted nearest first. Two people at the same airport cost one upstream request. It also honours upstream Retry-After. Other Workers round harder: reverse geocoding is cached for 30 days per 0.05° cell, and terrain answers are cached per roughly 10 m.

The cache layer is caches.default plus a small in-memory copy per isolate, with the write pushed off the response path:

ctx.waitUntil(api.put(req, res).catch(() => undefined));

Ten of the Workers also use the Rate Limiting binding, keyed per phone IP. The limits range from 4 per minute for generating a new offline map pack to 300 per minute for Streetwise’s small 3D building cells.

The planet in one R2 object

Wrist Map draws offline vector maps. The source is a single Protomaps basemap.pmtiles file for the whole planet, about 129 GB, stored in R2 for roughly $2 a month. Nothing is pre-cut per region. The Worker reads exactly the bytes it needs with ranged gets:

class R2Source implements Source {
  constructor(private bucket: R2Bucket, private key: string) {}
  getKey() { return this.key; }
  async getBytes(offset: number, length: number): Promise<RangeResponse> {
    const obj = await this.bucket.get(this.key, { range: { offset, length } });
    if (!obj) throw new Error(`missing ${this.key}`);
    return { data: await obj.arrayBuffer(), etag: obj.etag };
  }
}

The decoded vector tiles are then re-encoded into a compact format the watch can draw, and cached for 7 days. The cache key is the part I’m happiest with:

// What the watch tiles are made from: the format, the encoder and the
// basemap file. In every cache key, so a new basemap or encoder never meets
// tiles or chunks cached from the old one.
return `${TILE_VERSION}.${ENCODER_REV}.${reader!.etag}`;

Upload a new planet file and its R2 etag changes. Bump the encoder and its revision changes. Either way, stale tiles simply stop being addressed. There is nothing to purge.

Offline packs go to the watch in chunks of up to 12 KB, which is 16 KB once base64’d. Each chunk carries a hash of the tile it starts in and of the tile it ends inside. If the next chunk’s starting hash doesn’t match, the map changed between the two requests, and the watch fetches that tile again from its start instead of stitching two versions together. Chunks are cached too, so a retried chunk costs nothing.

Two other Workers read the same bucket with read-only bindings: Pistes lays ski runs over the basemap, and Streetwise builds 3D buildings from it. Uploading 129 GB with wrangler r2 object put was too slow, so it goes up with rclone.

Terrain: 6 GB, one ranged read per tile

Peak Horizon names the mountains you’re looking at. Its bucket holds a world elevation model (Copernicus GLO-90) plus peaks, places, water and snow masks: about 26,500 land cells, roughly 6 GB in 53,000 objects, inside R2’s free 10 GB.

Each elevation file holds 60×60 tiles, compressed with a plane predictor and Rice coding (3.1–3.8× at the near level). They sit behind a uint32 offset table, so once the table is cached in the isolate, any tile is a single ranged read.

The panorama itself, 360 directions by 15 rows, is ray-marched on the server, because the watch’s instruction watchdog would never allow it. It takes about 16 ms cold and 3–4 ms warm.

Once that terrain was in R2, other apps got it almost for free. True Sunset casts 1,440 rays against the same data to find when the sun actually drops behind the ridge, not the official sunset time. Refill reads the same bucket to find water near you. Native Wear OS and watchOS versions read the raw objects through a /v3 route cached at the edge.

The few stateful parts

Most Workers are stateless functions over R2 and the cache. Three things needed more:

Picking a map area on a watch screen is miserable, so for that the watch hands the job to the phone. It draws a QR code from raw bit modules, and a page served by the same Worker takes over.

What I’d change

Honest notes, since I’d want to read these in someone else’s post:

Each of those is a tooling problem more than an app problem, which is roughly why I find the tooling side interesting.

In numbers

Apps, watch faces and data fields 34
Workers (TypeScript) 14
R2 buckets 3 (terrain ≈ 6 GB, planet map ≈ 129 GB, ski areas)
D1 databases / Durable Object classes 4 / 1
Workers with rate limiting 10
Largest single response a watch face accepts 8 KB
Skyward answer, packed vs raw ≈ 3 KB vs 34 KB
Panorama compute, cold / warm ≈ 16 ms / 3–4 ms

All the apps are at links.silvadevlabs.com, a page that is itself a Worker building the list live from the store, with a cached snapshot as a fallback.