Home

How prform keeps working with no signal

Most gyms are concrete boxes with one bar of signal near the front door. If a workout app needs the network to save a set, it fails right when you need it most.

prform saves everything to the phone first and syncs in the background. Here's how that works.

The local database

Every workout, set and rest timer lives in SQLite on the device. The UI reads from it through TanStack DB live queries, so a tap updates the screen in the same frame.

const sets = useLiveQuery((q) =>
  q.from({ set: setsCollection }).where(({ set }) => eq(set.workoutId, workoutId)),
);

Syncing later

Writes go into an outbox. When the phone is back online, the outbox replays them against the server in order.

StepWhere it runs
Save the setPhone
Queue the writePhone
Apply itServer

The rule is simple: the phone is never waiting on the network.

That's the whole idea. The rest is making the edge cases boring.