[{"data":1,"prerenderedAt":90},["ShallowReactive",2],{"blog-what-offline-first-actually-costs-you":3},{"id":4,"title":5,"body":6,"date":72,"description":73,"draft":74,"extension":75,"image":76,"log":77,"meta":78,"navigation":79,"path":80,"seo":81,"stem":82,"tags":83,"__hash__":89},"blog/blog/what-offline-first-actually-costs-you.md","What Offline-First Actually Costs You",{"type":7,"value":8,"toc":68},"minimark",[9,16,19,27,32,39,50,55,62,65],[10,11,12],"p",{},[13,14,15],"strong",{},"The shape of the problem",[10,17,18],{},"Porting a POS system to a Wails desktop shell meant going from \"Postgres is the only database that exists\" to \"there are now two databases, and one of them is on a laptop that might be in someone's bag on a bus for six hours.\" SQLite became the local store, UUID-based IDs replaced the auto-increment assumption baked into a year of backend code, and an outbox/queue pattern became the bridge between \"what happened on this device\" and \"what the server eventually needs to know.\"",[10,20,21,22,26],{},"The UUID switch sounds cosmetic until you remember ",[23,24,25],"em",{},"why"," sequential IDs are dangerous in a multi-writer world: two branches, both offline, both ring up sale #4821. In a single-database world that's not even a possible sentence. In an offline-first world it's Tuesday. UUIDs solve the collision, but they don't solve the harder question underneath — ordering. If two offline devices modify the same stock record before either has seen the other's changes, \"last write wins\" is a decision, not a fallback. Someone has to make it on purpose.",[10,28,29],{},[13,30,31],{},"Why the outbox pattern earns its complexity",[10,33,34,35,38],{},"The naive version of sync is: write locally, then also try to write remotely, and if the remote write fails, retry it later somehow. This works exactly until \"later somehow\" meets a queue that's supposed to survive an app restart, a power loss, or a laptop that's closed for a long weekend. The outbox pattern — write the local change ",[23,36,37],{},"and"," a durable record of \"this needs to go out\" in the same transaction — turns sync from a best-effort side-channel into something you can reason about. If the outbox row exists, the sync worker will eventually see it. If it doesn't, the transaction never committed. No in-between state.",[10,40,41,42,45,46,49],{},"The part that doesn't show up in the architecture diagram is the discipline this demands from the rest of the codebase. The existing rule — ",[23,43,44],{},"no optimistic UI for money or stock-changing operations"," — turns out to be exactly the right instinct once you're offline-first, for a slightly different reason than intended. Optimistic UI was originally about not lying to the user about what's confirmed. Offline, it's about not lying to the ",[23,47,48],{},"sync layer"," either — every write that touches inventory or a ledger has to be something the outbox can replay safely, which means idempotency isn't a nice-to-have, it's the whole game. If a sync retry can double-apply a stock deduction because the network blipped between \"server received it\" and \"client got the ack,\" the offline story collapses the first time it matters.",[10,51,52],{},[13,53,54],{},"Multi-tenancy makes it worse in a specific way",[10,56,57,58,61],{},"Running a per-company SKU-scoping audit at the same time as the offline work isn't a coincidence of timing — the two problems compound. Offline-first already means \"reconcile what this device believes with what the server believes.\" Multi-tenant means \"reconcile it ",[23,59,60],{},"within the boundary of one company's data, correctly, every single time,"," including for a device that's been offline long enough to miss a tenant-scoping change entirely.\" A bug that leaks one company's data into another's dashboard is bad. The offline version of that bug — a device that cached stale scoping rules and now needs to be told, gently, that half of what it queued no longer applies — is worse, because it doesn't show up in testing. It shows up three weeks later when someone's laptop finally reconnects.",[10,63,64],{},"The honest takeaway: offline-first isn't a sync feature you bolt onto a finished app. It's a constraint that should have shaped the backend from the start, and when it arrives late — as it usually does — the real work isn't writing the sync engine. It's going back through every mutation in the system and asking, one at a time, \"what happens if this runs twice, out of order, against stale scoping rules?\" That audit is slower and less glamorous than shipping the outbox queue. It's also the only part that actually prevents 2am incidents.",[66,67],"hr",{},{"title":69,"searchDepth":70,"depth":70,"links":71},"",2,[],"2026-09-19","\"Everyone loves the pitch for offline-first: the cashier's laptop drops WiFi mid-sale, and nothing breaks. The app doesn't care. Sync happens later, quietly, in the background. It's a great story to tell a client.",false,"md",null,42,{},true,"/blog/what-offline-first-actually-costs-you",{"title":5,"description":73},"blog/what-offline-first-actually-costs-you",[84,85,86,87,88],"go","react","wails","postgresql","sqlite","P88k2LCInN3GCLbJ5T4xV6yjEuP8pqZOlzjPQa1pa-k",1793965568110]