AI Integration Quick Reference
AI Integration Quick Reference
OfflineConfig to your AppSettings. Until you do, the SDK behaves exactly as before: no local store is opened and no native module is loaded. This page covers the minimal setup; for every tunable option see the Configuration & API Reference.
1
Requirements
Offline support requires CometChat React Native Chat SDK 4.2.0 or later.The local database is provided by a native module that you install in your app. It is an optional peer dependency of the SDK, so installing the SDK never requires it:If you are new to the SDK, complete the standard setup first; the steps below only add offline configuration to your existing
@op-engineering/op-sqlite is a native module. In Expo, use a development build or expo prebuild — offline does not run in Expo Go (the SDK then runs online-only). Pick an op-sqlite release that supports your React Native version.init.2
Build an OfflineConfig
Construct an
OfflineConfig and set enabled: true. Every other option has a sensible default, so set only what you need. Invalid values are normalised to the default; they are never rejected.- TypeScript
- JavaScript
3
Attach it to AppSettings
Pass the config to
AppSettingsBuilder.setOfflineConfig(...). To enable with all defaults instead of building a config, use the offline(boolean) shorthand.- TypeScript
- JavaScript
If you call both
setOfflineConfig(...) and offline(boolean), the explicit OfflineConfig wins — its enabled value is authoritative.4
Initialize the SDK
Pass the settings to
CometChat.init(...) as you do today. No other call changes.- TypeScript
- JavaScript
On a relaunch with a saved login,
init also starts offline support, and waits for it for up to 8 seconds. Add your cache-reset and outbox listeners straight after await CometChat.init(...) resolves. Anything raised during startup is delivered just after init resolves.5
Verify it is active
Call
CometChat.isOfflineEnabled(). It returns true only while offline support is actually active for the logged-in user. It is false before anyone logs in (even when you enabled it in AppSettings), after logout or session expiry, and when the local store or the encryption key store cannot open. Read it at the moment of each decision and keep no copy of the result.- TypeScript
- JavaScript