Lurker News
Hey there HN! We’re Joe and Stopa, and today we’re open sourcing InstantDB, a client-side database that makes it easy to build real-time and collaborative apps like Notion and Figma.

Building modern apps these days involves a lot of schleps. For a basic CRUD app you need to spin up servers, wire up endpoints, integrate auth, add permissions, and then marshal data from the backend to the frontend and back again. If you want to deliver a buttery smooth user experience, you’ll need to add optimistic updates and rollbacks. We do these steps over and over for every feature we build, which can make it difficult to build delightful software. Could it be better?
We were senior and staff engineers at Facebook and Airbnb and had been thinking about this problem for years. In 2021, Stopa wrote an essay talking about how these schleps are actually database problems in disguise [1]. In 2022, Stopa wrote another essay sketching out a solution with a Firebase-like database with support for relations [2]. In the last two years we got the backing of James Tamplin (CEO of Firebase), became a team of 5 engineers, pushed almost ~2k commits, and today became open source.
Making a chat app in Instant is as simple as

    function Chat() {
      // 1. Read
      const { isLoading, error, data } = useQuery({
        messages: {},
      });

      // 2. Write
      const addMessage = (message) => {
        transact(tx.messages[id()].update(message));
      }

      // 3. Render!
      return
    }
Instant gives you a database you can subscribe to directly in the browser. You write relational queries in the shape of the data you want and we handle all the data fetching, permission checking, and offline caching. When you write transactions, optimistic updates and rollbacks are handled for you as well.

Under the hood we save data to postgres as triples and wrote a datalog engine for fetching data [3]. We don’t expect you to write datalog queries so we wrote a graphql-like query language that doesn’t require any build step.
Taking inspiration from Asana’s WorldStore and Figma’s LiveGraph, we tail postgres’ WAL to detect novelty and use last-write-win semantics to handle conflicts [4][5]. We also handle websocket connections and persist data to IndexDB on web and AsyncStorage for React Native, giving you multiplayer and offline mode for free.
This is the kind of infrastructure Linear uses to power their sync and build better features faster [6]. Instant gives you this infrastructure so you can focus on what’s important: building a great UX for your users, and doing it quickly. We have auth, permissions, and a dashboard with a suite tools for you to explore and manage your data. We also support ephemeral capabilities like presence (e.g. sharing cursors) and broadcast (e.g. live reactions) [7][8].
We have a free hosted solution where we don’t pause projects, we don’t limit the number of active applications, and we have no restrictions for commercial use. We can do this because our architecture doesn’t require spinning up a separate servers for each app. When you’re ready to grow, we have paid plans that scale with you. And of course you can self host both the backend and the dashboard tools on your own.
Give us a spin today at https://instantdb.com/tutorial and see our code at https://github.com/instantdb/instant
We love feedback :)
[1] https://www.instantdb.com/essays/db_browser
[2] https://www.instantdb.com/essays/next_firebase
[3] https://www.instantdb.com/essays/datalogjs
[4] https://asana.com/inside-asana/worldstore-distributed-cachin...
[5] https://www.figma.com/blog/how-figmas-multiplayer-technology...
[6] https://www.youtube.com/live/WxK11RsLqp4?t=2175s
[7] https://www.joewords.com/posts/cursors
[8] https://www.instantdb.com/examples?#5-reactions

Comments (297) 98 threads

Earlier comments
the_king1 reply#
This is really cool. Curious to see more about how the database can be queried. I don't write much SQL these days, and I have no dedication to Postgres, but it does integrate with pretty much everything. Also curious how I'd go about the basics in Instant.

For example, creating a user table and ensuring that emails are unique - I've done it 50 times with Postgres. Is that part built out yet?
Very cool. Appreciate the "Don't Make Me Think" API.
(written with aqua)

stopachka#
> creating a user table and ensuring that emails are unique - I've done it 50 times with Postgres. Is that part built out yet?

Yes. Auth comes out of the box with Instant. You get support magic code-based auth, Google OAuth, and have an option to extend it using your own backend if you prefer.
P.S Aqua seems very cool; I broke my thumb 6 months ago, and would have definitely appreciated a tool like that.

cheema331 reply#
Is it correct to assume that if your existing application has lots of data stored in standard PostgreSQL tables, you can't have InstantDB sync with it?

In other words it primarily targets brand new projects or projects that can completely migrate away from their current database?

nezaj#
We're currently working on a Postgres adapter. If you have an existing app and would be interested in using Instant with it, please send us a note: founders@instantdb.com

The way the Postgres adapter would work: You give us your database url [1], and Instant handles the real-time sync. [2]
For roll-out, we'll test it ourselves first and then take on beta users.
[1] Encrypted at rest: https://github.com/instantdb/instant/blob/main/server/src/in...
[2] Here's a fun 'pg introspection' function: https://github.com/instantdb/instant/blob/main/server/src/in... . You can take sneak peak through codebase by searching 'byop'.

kabes2 replies#
From skimming through the site, it's not clear to me how the BE looks like. Obviously, the BE part is the hard/interesting part. Is that open-source and/or self deployable? Or is this fixed to a backend-as-a-service you guys provide?
ochiba2 replies#
Sounds conceptually similar to Zero: https://zerosync.dev/

I haven't looked in detail yet — what are the main differences relative to Zero?

pbreeze1 reply#
I think it would be difficult to compare at this point, as there aren't many details about Zero outside of the blog on their landing page. I believe it's very much in early (but active) development.

From that blog: > We are working toward a source release in summer 2024 and an open beta EOY 2024.

pbreeze#
Hadn't seen this, thanks!
yr1337#
Zero is by the Replicache team and they are really nice guys. I've interacted with Aaron Boodman quite a bit in their Discord and he was very responsive and helpful, and took a lot of my comments into consideration in improving the product. It's a very hot space which IMO will revolutionize how we build GUIs IMO. Replicache is a bit hard to grasp at first but the nice thing is you bring your own DB (vs. use a service). I think this project needs more recognition. I would hate to see them fade just because they don't have the fancy backers like YC and the usual crowd. If they keep at it they might prevail since VC-backed startups like InstantDB tend to sell out and flame out.

Load more comments