React Native support is available from modelence v0.19.0.
localStorage and window, you configure the client with configureClient so the SDK knows how to store auth tokens, read device dimensions, and resolve server URLs.
Setup
1
Install dependencies
Add Modelence to your React Native project:You’ll also need
@react-native-async-storage/async-storage (or any other persistent key-value store) to persist the auth token across app restarts.2
Configure the client
Call
configureClient once, before your app mounts — for example at the top of your entry file (App.tsx or index.ts).3
Wrap your app with AppProvider
Load the persisted auth token before mounting your app, then wrap your root component with
AppProvider:ClientConfig reference
Using authentication
Auth functions work the same way as on the web:Calling methods
callMethod works without any changes — it automatically prepends baseUrl to every request:
Live queries and WebSockets
Live queries connect over WebSocket tobaseUrl. No additional configuration is needed beyond configureClient:
OAuth sign-in
For Google or GitHub sign-in, Modelence opens an OAuth URL in the browser. On React Native, provideopenUrl in configureClient so the SDK can hand off to the device browser via Linking.openURL:
loginWithOAuth with the returned token.
Notes
- No
AppProviderrequired for auth-only usage. You can callloginWithPassword,callMethod, etc. withoutAppProvider. The provider is needed only if you use React hooks likeuseSessionoruseQuery. - Token persistence is your responsibility. Modelence calls
setAuthTokenandgetAuthTokenbut does not bundle a storage library. UseAsyncStorage,expo-secure-store, or any store that fits your security requirements. orientationinClientInfois optional. Passnullif your app does not track orientation.