β€’

tech

More apps should be local-first

Some apps are made to be local, but currently close to none really are. The tech stack for local apps is already here, and this is how I am using it to build my vision for local-first.


Sandro Maglione

Sandro Maglione

Software

Why are so many apps cloud-based? 🀨

Most of the apps I use would work better offline. Examples are workout tracking, journals, personal finance.

Plus you can sprinkle some syncing to move your data between devices + backups ✨

Well, this is my vision for truly local apps πŸ‘‡


Diet tracking online?

I am using an app to track what I eat.

Every time I open it, it takes 2+ seconds to load my data from the cloud 🀦

And the app doesn't even work offline (of course) 🀦

Why a diet tracking app needs to push my (personal) data on the cloud with every interaction? πŸ™Œ

Answer: it doesn't.

It gets so bad that the app actually displays an error when you are offline. No data is stored locally, it's all cloud-based.
It gets so bad that the app actually displays an error when you are offline. No data is stored locally, it's all cloud-based.

That's the perfect example for the kind of app that is made for local-first:

  • Deals with private data
  • Single-user without collaboration
  • Great benefits for working offline

The same as any other tracking app (timers, workouts, mood).

But none of them it's truly offline-first/local-first 🫠

Local-only is a solved problem

I have already published plenty of resources for local-only (e.g. Local-only calories tracker app).

With solutions like IndexedDB (Dexie), SQLite, Pglite, local-only storage is solved 🫑

All it takes is calling store pointing at your local storage, instead of fetch to send everything down the network.

It makes for an astounding UX, and an even faster and more satisfying DX. Win-win.

And indeed, many apps would work without issues local-only, diet tracking it's again a perfect example πŸ’πŸΌβ€β™‚οΈ

Syncing: backup and multi-device support

The major issue with local-only is your data being trapped on a single device.

Even if it's just me, I may want to view/share the same data on multiple of my devices πŸ€”

That's the role of the cloud. But it starts and stop there for something like diet tracking: backup my data (in case a device is lost) and share my data to other devices.

CRDTs are the solution

Syncing can get tricky. But reducing the scope to backup and sync makes it way easier πŸ™Œ

Especially if you don't need features like real-time collaboration (why would you? It's just you, you are not supposed to use 2 device at the same time).

In this context, CRDT can do all the heavy-lifting:

With solutions like Loro and Yjs, CRDTs in TypeScript are a solved problem (more or less) 🫑

In its most simple form, it comes down to a single sync endpoint (that stores the client updates, and responds with the latest snapshot).

Multi-user/device auth

The server is also ideal for Authorization πŸ”—

I am about to release an open-source web sync engine that includes syncing and auth:

  • Client owns its own workspace (offline)
  • Client (owner) notifies server, syncing starts
  • Client (owner) can share access to other clients
  • Server keeps backup of data and tokens for each client (Auth+Storage)

That's my vision for my personal apps:

  • I can use them offline/single-device
  • I can sync for backups and multi-device
  • I can share access to other devices, while still having full auth control

Keep an eye open for more apps like this in the future (and not just from me πŸ‘€)


Countdown started for the Effect Days.

Topic reveal: my talk will be all about Effect on the Frontend πŸš€

Be ready for a great experience, and a full recap from me on this newsletter πŸ”œ

See you next πŸ‘‹

Start here.

Every week I dive headfirst into a topic, uncovering every hidden nook and shadow, to deliver you the most interesting insights

Not convinced? Well, let me tell you more about it