-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add local DB recommendation for reactions and replies (#778)
* first pass * inc edits from Naomi and Ry <3
- Loading branch information
Showing
5 changed files
with
37 additions
and
10 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,36 @@ | ||
--- | ||
sidebar_label: Local-first cache | ||
sidebar_label: Local-first architecture | ||
sidebar_position: 3 | ||
description: "If you're building a production-grade app, be sure to use a local-first architecture to help you build a performant app." | ||
--- | ||
|
||
# Use local-first architecture | ||
|
||
If you're building a production-grade app, be sure to use a local-first architecture to help you build a performant app. Using this local-first architecture, the client prioritizes using the local cache on the device where it’s running. | ||
If you're building a production-grade app, be sure to use a local-first architecture to help you build a performant app. Using a local-first architecture means building your app so a client prioritizes using local storage on the device where it’s running. | ||
|
||
For example, use the XMTP SDK to initially retrieve existing message data from the XMTP network and place it in the local cache. Asynchronously load new and updated message data as needed. Build your app to get message data from the local cache. | ||
For example, use the XMTP SDK to initially retrieve existing message data from the XMTP network and place it in local storage. Then, asynchronously load new and updated message data as needed. | ||
|
||
**When building a web app with the [React SDK](https://github.com/xmtp/xmtp-web/tree/main/packages/react-sdk), the local-first architecture is automatically provided by the SDK.** | ||
|
||
Here’s an overview of how your app frontend, local cache, client SDK, and the XMTP network work together in this local-first approach: | ||
Here’s an overview of how your app frontend, local storage, client SDK, and the XMTP network work together in this local-first approach: | ||
|
||
import localfirst from '/docs/build/img/local-first-arch.jpeg'; | ||
|
||
<img src={localfirst} style={{width:"450px"}}/> | ||
|
||
- When building a web app with the [xmtp-js SDK](https://github.com/xmtp/xmtp-js), you can use the browser `localStorage` as the local cache to store encrypted data, decrypting data each time before display. You might also consider [using Dexie to manage your web app's local data](#manage-local-data-with-dexie-in-a-web-app-built-with-xmtp-js). | ||
## Mobile apps | ||
|
||
When building a mobile app with the XMTP V3 [React Native](https://github.com/xmtp/xmtp-react-native), [Android](https://github.com/xmtp/xmtp-android), and [iOS](https://github.com/xmtp/xmtp-ios) SDKs, LibXMTP will [create and manage a local database](/docs/concepts/v3/group-chat#local-database-and-syncing) for you. | ||
|
||
However, you should create and manage an additional separate local database if your app: | ||
|
||
- Supports [reactions](./messages/reaction) and [replies](./messages/reply) | ||
- Supports 1:1 messaging backed by [XMTP V2 infrastructure](/docs/concepts/v2/architectural-overview.md) | ||
|
||
- When building native iOS and Android mobile apps, you can use the device's encrypted container as the local cache to store decrypted data. | ||
Use this separate local database to store reactions and replies content types, enabling your app to performantly display them with their referenced messages when rendering message lists. | ||
|
||
## Web apps | ||
|
||
- When building a web app with the [React SDK](https://github.com/xmtp/xmtp-web/tree/main/packages/react-sdk), the local-first architecture is automatically provided by the SDK. | ||
|
||
- When building a web app with the [xmtp-js SDK](https://github.com/xmtp/xmtp-js), you can use the browser `localStorage` as the local cache to store encrypted data, decrypting data each time before display. You might also consider [using Dexie to manage your web app's local data](#manage-local-data-with-dexie-in-a-web-app-built-with-xmtp-js). | ||
|
||
For more performance best practices, see [Optimize performance of your app](/docs/get-featured) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters