Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

offline-support-cover

Hello all 👋🏼

Since offline support has been such a highly requested feature, we've been hard at work updating our SDKs to work offline. We've started with the Flutter SDK and plan to add support in the other client SDKs after some testing and feedback.

For details on the design and implementation, please take a look at our RFC.

Getting Started

First, you need to use this branch of the SDK. You can do so by updating the pubspec.yaml. Refer to the Dart docs for more details on how to do this.

Next, to enable offline support, call await client.setOfflinePersistency(status: true) like:

client = Client()
  .setEndpoint(constants.appwriteEndpoint)
  .setProject(constants.appwriteProjectId)
  .setSelfSigned(status: constants.appwriteSelfSigned);

// initialize offline support and process queued write operations
await client.setOfflinePersistency(status: true);

One very important thing is that write operations will not resolve until online again, so you have to update your code to update optimistically. For example:

  void submitTodo() async {
    final messenger = ScaffoldMessenger.of(context);
    final newTodo = Todo(
      content: inputController.text,
      id: ID.unique(),
    );

    // create optimistically
    databases.createDocument(
      databaseId: constants.appwriteDatabaseId,
      collectionId: constants.appwriteCollectionId,
      documentId: newTodo.id,
      data: {"content": newTodo.content, "isComplete": newTodo.isComplete},
    ).catchError((e) {
      // handle errors
      messenger.showSnackBar(createErrorSnackBar(e.toString()));
      todos.remove(newTodo);
    });

    inputController.text = '';
    setState(() {
      todos.add(newTodo);
    });
  }

For a sample app with Offline Support, check out our Todo with Flutter.

Next Steps

Join us on Discord if you need any help. We'd love to get your feedback on how offline support works for you, so feel free to post below!

You must be logged in to vote

Replies: 23 comments · 31 replies

Comment options

It would nice, if we can difference between the document that is already sync in server & document that is not sync.

distinction will allow help, show some warning to user or put some limitation on deleting document or etc... possible scenario.

You must be logged in to vote
0 replies
Comment options

Hi, i need it in the 9,0,0 version flutter . Thanks

You must be logged in to vote
3 replies
@stnguyen90
Comment options

stnguyen90 Apr 25, 2023
Maintainer Author

@hortigado, what exactly are you looking for from 9.0.0?

@hortigado
Comment options

@stnguyen90 hi, relationships, I get the error User class does not exist

@qyptor
Comment options

@stnguyen90 sir its been a long time, you should add the offline support ( beta ) to the latest flutter sdk. waiting for it from years

Comment options

Wow finally, awesome!! You just won me as a new developer using appwrite over competing products! 👍

You must be logged in to vote
0 replies
Comment options

I am not sure if it's supported yet. If it's already then it's HUGE...

Request is documents gets Sync Attribute data automatically that have changed from server. Which mean, if let's say user A created a order, then went offline and other side some other user B updated the item in that order. So, next-time when user A come online he want to see latest change to do that right now whole documents have to be re-fetched. As, in client side it doesn't know which portion of data have changed.

So, in future what could possible is when user A back-online a connection gets open immediately between client
& server and as Appwrite server keeps track of which part have changed it try to send only those and then that changes get saved locally.

You must be logged in to vote
0 replies
Comment options

Hello, I have been testing it and it works very well.

  • A feature that could be implemented I think would be to be able to queue "listDocuments" requests and allow an action to be performed when the request is made when the user connects to the Internet. This would help, for example, if the user goes to a page but does not have the data stored locally, send an alert that connects to the Internet and when the user connects to the Internet, in the background to be able to update the information on the page;
  • The same for "createDocument" to be able to throw an alert or something when the information is sent to appwrite.
You must be logged in to vote
4 replies
@Grober976
Comment options

Hola @hortigado queria saber si te funciono para la version 9.0.0

@hortigado
Comment options

@Grober976 si pero aún está muy verde, por ejemplo no puedes editar un documento creado offline. Ahora estoy implementando con el paquete brick.

@Grober976
Comment options

Gracias, Mi otra duda iba a que setOfflinePersistency. no esta definido para client, ¿lograste ver eso? Gracias Nuevamente

@hortigado
Comment options

@Grober976 seguramente no estás usando la rama offline de GitHub ya que no está en la rama principal está funcion

Comment options

Hi I am so happy about this new feature and hope to use it in the future instead of my own solution.

The only questions/wishes I have would be that I could watch documents or stuff offline via realtime or listen to the local database somehow. Also I wanted to ask if theres a possibility to insert executions/Objects as documents for example I have some functions that return me a document of a certain collection. But the thing that would be very helpful for me would be away to look for something offline first before asking the server for it or even better look only offline for it.

But as said before most of all I am very thankful for this solution and think your doing great work at appwrite :)

You must be logged in to vote
0 replies
Comment options

This would be amazing. What is the theoretical timeline for this coming to Apple SDK - 6 months, a year, more?

You must be logged in to vote
1 reply
@luke-stdev001
Comment options

I'm interested to know this as well. We're considering this for a sizeable project, and offline support in some form in both Swift and Kotlin SDK's would be incredible.

Comment options

Awesome feature.
@stnguyen90 @eldadfux
It could be nice to use the most relible local storage for every platform.
For example, specially for Flutter
Mobile: SQLite (ACID + https://www.sqlite.org/testing.html)
Web: SQLite+Wasm when browser support it or IndexDB in other case.
https://drift.simonbinder.eu/web/#storages

Keen to see solution :)

You must be logged in to vote
0 replies
Comment options

Hi Could you please let me know when flutter offline support will be production ready?
Just waiting for it to migrate to Appwrite.

You must be logged in to vote
7 replies
@hortigado
Comment options

although electricsql seems much better to me.

@alterhuman
Comment options

Yeah I was planning to go for managed Postgres + Electric if Appwrite will take time to provide offline support.

@cahofmeyr
Comment options

I am waiting for AppWrite to support Postgres so that we can integrate PowerSync with it

@sabinjose
Comment options

I am stuck with firebase currently. Planning to swich to Appwrite or some other self hosted solution soon. Offline support is a blocker to do that.

@dhonig-weizmann
Comment options

Do you have an example using brick? that would be most helpful

Comment options

I prefer Isar Database for flutter offline database support

You must be logged in to vote
1 reply
@hortigado
Comment options

Have you encountered any problems or limitations with isar?

Comment options

Two questions:

  1. What happens to the data after the app gets closed?
  2. What happens to the pending requests if the app gets closed?
You must be logged in to vote
0 replies
Comment options

Any progress on this lately? I'm especially looking forward to iOS.

You must be logged in to vote
0 replies
Comment options

Any updates? Current version is 11.0.1 and offline support is reporting 9.0.0 and is failing. Any plans on this? Roadmap?

You must be logged in to vote
0 replies
Comment options

I am also looking for updates on this Offline Support features. It's a must feature for any mobile app.

Thanks.

You must be logged in to vote
0 replies
Comment options

I am also looking for an update and any approximate timelines for offline sync support. A must for any mobile apps these days.

Thanks.

You must be logged in to vote
0 replies
Comment options

Offline sync is also great for any web app these days! OOTB support for general Progressive Web App standards would be great.

You must be logged in to vote
0 replies
Comment options

yeah this is a must feature. Looking forward to have it

You must be logged in to vote
0 replies
Comment options

Hello, does anyone have an example of how to use Appwrite with brick?

You must be logged in to vote
0 replies
Comment options

Looking forward for appwrite offline solution.

Currently I'm considering Supabase + Powersync but the cost would be $74 monthly. Appwrite would be only $15.

You must be logged in to vote
2 replies
@Musta-Pollo
Comment options

You can consider electricsql

@laurentpayot
Comment options

@Musta-Pollo electricsql is interesting!

Comment options

Did this ever get implemented? @stnguyen90

You must be logged in to vote
3 replies
@samuel-kings
Comment options

Did this ever get implemented? @stnguyen90

Not at the moment

@algoflows
Comment options

Insane, clear market demand for it. Offline support is becoming more and more relevant for mobile experiences. Mongo atlas realm sync provides it, firebase provide it, aws appsync with amplify provide it, convexdb is building it, electricsql is providing it and so is powersync. After years of asking for it, being told it would be implemented, years later, still not implemented. It's a crying shame appwrite could have been a leader in this regard providing a legitimate alternative to firebase.

@laurentpayot
Comment options

Note that with its new SQL database, Firebase is now also a legitimate alternative to Appwrite 😉

Comment options

Hey there! What's the current status on that? Is there a timeline when this gets implemented in stable for flutter? 😊 @stnguyen90

You must be logged in to vote
0 replies
Comment options

Well as no one from appwrite is taking the time to answer. Time to move.

You must be logged in to vote
0 replies
Comment options

Hey Appwriters, I know many of you are anxiously waiting for updates on this. I'll do my best to explain the current situation of offline support and what we want to try next.

Last year we’ve spent multiple months exploring different directions for the implementation of offline support. We ended up going with the direction shared on this thread and as described in this RFC, but soon realized a very generic solution would require a different approach.

Our main challenges came down to the added complexity introduced by relationships that were launched as an experiment at around the same time and a limited ability to properly imitate the querying capabilities of the backend when offline. We don’t want to compromise on the level of quality Appwrite developers should be getting.

What’s next?

We’re exploring new directions. One of the directions I’m personally very curious about is using the Appwrite backend as a complimentary tool that heavily rely on a solid offline first or offline-only database and uses Appwrite backend capabilities mainly for remote syncing and conflict resolutions. SQLite can be one good example, but there are more, we might even have support for a few of this. As always, we're always happy to hear your feedback and ideas. Feel free to drop them in the comments.

What’s now?

Building offline first capabilities with Appwrite is still very much possible for many use cases even if not through a built in solution. Yes it requires more frontend code, thinking and adjustments, but for sure possible.

If you’re not into the DIY approach, you can also integrate Appwrite with other tools that do offer what you’re looking for, nothing wrong about that, and Appwrite was designed to integrate well with other tools, competitive to Appwrite or not.

If you need help understanding how to go about it. Our Discord server is a great way to start, our team would also love to learn about your use cases as we explore new and creative directions to solve this problem with a quality solution.

If both options don’t cut it for you, the best option would be to use a different tool that is better for this job, and revisit Appwrite when we do have a better solution for your offline support needs.

You must be logged in to vote
10 replies
@hortigado
Comment options

Even other tools for online support cannot be implemented because the flutter sdk does not return the token with google to maintain the offline login. I had to modify the code a bit to be able to implement brick with the appwrite flutter sdk

@eldadfux
Comment options

@Curryking31 I appreciate the feedback and truly apologies for the lack of updates, no good excuses, but we've been working very hard improving the product, and with the community constant growth its been challenging to keep track of everything. We noticed that we didn't follow up on queries here after it was mentioned on our Discord.

No surprise here, but its very hard for me to give an exact timeline for offline support. Some of our higher priorities for the databases team is to examine our relationships experiment and come up with more solutions for uses case that needs join like capabilities, more things on the plans that are equally urgent is introducing aggregation methods, batch operations and transactions. I'll make sure to work with our product team so offline support is also high on our lists, we also plan to expand the databases team, so hopefully this could also help us move faster.

Another idea that was brought today by @Meldiron was to try and provide a few official plugin to fill this gap in the product to some degree, its something we will check in the next few days.

We did announce our public roadmap, we try to keep as up to date as possible, it includes most stuff we're working on, aside of a few special surprises to keep things spicy. You can learn more about it in this post I shared: https://appwrite.io/blog/post/public-roadmap-announcement

@cahofmeyr
Comment options

We would like to make PowerSync work with Appwrite, but this would require Postgres access with logical replication enabled. PowerSync will also soon have support for MySQL in case that's another route to work with Appwrite.

Are there any possibilities here?

@metaspook
Comment options

We would like to make PowerSync work with Appwrite, but this would require Postgres access with logical replication enabled. PowerSync will also soon have support for MySQL in case that's another route to work with Appwrite.

Are there any possibilities here?

I'm thinking of even if AppWrite doesn't have it's own local-first feature
Flutter + PowerSync + AppWrite
could be a full fledge local-first app stack.. 💪🔥

@AliYar-Khan
Comment options

There is a fork of SQLite that claims to have offline feature https://github.com/tursodatabase/libsql

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
💡
Ideas
Labels
None yet
Morty Proxy This is a proxified and sanitized view of the page, visit original site.