#how can i integrate sqllite for an offline-first application backed with convex?

4 messages · Page 1 of 1 (latest)

whole ibex
#

Do you know any examples that have integrated sqllite for a local-first application?

hollow hillBOT
#

Hi @whole ibex. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

Convex is working on native offline support for local-first applications, but it's not yet fully available. Based on the knowledge sources, here's what we know about integrating SQLite for offline-first applications with Convex:

Current Status of Offline Support

Convex is planning to release a native, deeply integrated offline offering in late 2024 according to their roadmap What is Sync?. Currently, there are a few approaches you can take:

Approaches for SQLite Integration

  1. Object Sync Engine: Convex is developing an object sync engine that will make the platform suitable for building local-first apps. In their planned implementation, they mention:

    "We'll also use IndexedDB for our first release. We eventually want our sync engine to work across Web, mobile, and desktop, so we'll probably switch to some form of SQLite in the future." An Object Sync Engine for Local-first Apps

  2. Integration with Replicache: There's an example of integrating Convex with Replicache for offline sync mentioned in the documentation: github.com/sujayakar/replicache-convex

  3. Upcoming Local API: Convex is working on a local API that will look similar to server-side queries:

    const isFriend = useLocalQuery(async (ctx) => {
      const friendship = await ctx.localDb.query("friendships")
        .withIndex("by_from_to", q => q.eq("from", user).eq("to", friend))
        .unique();
      return friendship !== null;
    });
    

    This will be paired with local mutations that sync with server-side mutations An Object Sync Engine for Local-first Apps.

#

Examples and Explorations

There are a few examples mentioned in the knowledge sources:

  1. Automerge with Convex: Ian has explored using Automerge with Convex for local-first text editing, which you can find at Going local-first with Automerge and Convex.

  2. Legend-State Plugin: There's a community-developed plugin for Legend-State that provides offline-first capabilities with Convex, though it's not clear if it specifically uses SQLite. You can find it at github.com/jmeistrich/convex-legendstate.

For mobile applications specifically, there was a question in the Discord about syncing local storage with Convex for an Expo app, but no specific solution was provided in the knowledge sources.

The Convex team seems to be actively working on this area, so you might want to check their latest documentation or join their Discord server for the most up-to-date information on offline-first capabilities.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: