Designing offline-first forms that never lose data

By Next Template · Engineering · 4 min read ·

Lessons from building an inspection app for places without signal: save locally first, sync in order, show honest status and make every server write idempotent.

Cover image for "Designing offline-first forms that never lose data"

Losing a half-finished form is one of the most frustrating things software can do to a person. It happens most often to people working in the field, in basements, on trains or in rural areas, where the connection comes and goes. While building an inspection app for surveyors, we learned that offline-first forms are less about clever technology and more about a few firm rules.

Rule one: save locally before anything else

Every change is written to local storage the moment it happens. In the browser that usually means IndexedDB, which can hold structured data and binary files such as photos. The network is treated as an optional extra, not as the place where data lives.

Use an outbox

Alongside the saved data, each change is added to an outbox: a simple ordered list of operations waiting to reach the server. The outbox makes sync predictable, because it records intent rather than trying to compare two copies of the same record later.

Keep the format boring

Store plain objects with explicit version numbers. When the form changes in a future release, a small migration step can upgrade old records instead of throwing them away.

Rule two: sync in order, and retry patiently

A sync worker sends outbox items one by one, in the order they were created. When a request fails because the connection dropped, the worker waits and tries again with growing delays. When a request fails because the server rejected the data, the item is marked for attention instead of being retried forever.

  • Photos upload directly to storage through short-lived signed URLs, so large files never pass through the application server.
  • The worker pauses when the device is low on battery and resumes when charging or back on a stable connection.
  • A manual sync button exists for the moments when people simply want reassurance.

Rule three: show honest status

People trust what they can see. Each record shows whether it is saved on the device, waiting to sync or safely on the server. A small log lists recent sync activity with times. When something needs attention, the message says what happened and what to do, in plain language.

Rule four: make every server write idempotent

Retries mean the server will sometimes receive the same operation twice. Each operation carries a unique identifier created on the device. The API stores those identifiers and ignores repeats, so a flaky connection never creates duplicate inspections or duplicate photos.

Conflicts are rarer than you think

We expected conflicts to be the hardest part. In practice, one person usually owns a record while they work on it. A simple rule, where the latest change to each field wins and every change is kept in a history, covered almost every real case.

Testing on real devices

Emulators lie about storage limits and battery savers. Test on the cheapest device your users actually carry, fill its storage, switch it to airplane mode in the middle of an upload and see what happens. Every bug we found this way would have reached production otherwise.

Wrapping up

Offline-first forms come down to saving locally, syncing in order, being honest about status and making the server tolerant of repeats. Follow those rules and people stop worrying about the connection and get on with their work.

Putting it into practice

If you want to try these ideas, start small. Pick one screen, one job or one page in a project you already know well, apply a single change from this post and measure the result for a couple of weeks. Small, measured changes are easier to explain to a team and much easier to undo if they do not work.

We write these notes from real client work, so every recommendation here has been tested on a production system. If you have a question about engineering, a different experience to share, or a project where these ideas could help, the contact page is the quickest way to reach us, and we read every message.

  • Offline-first
  • PWA
  • IndexedDB
  • UX

Back to all articles · See related projects

Have a project in mind?

Tell us about the problem you want to solve. We reply within two working days with honest feedback and a sensible first step.

Start a conversation