@offline-protocol/id-react-native@0.3.3 for hosted email sign-in, profiles and connections in a React Native or Expo app. Create an application in the developer portal. The appId prop is the application’s public identifier, not a secret key.
Prerequisites
- Node.js
18.xor higher - React
18.xor19.x - React Native or Expo
- A package manager:
npmoryarn
Install
Install the SDK and its peer dependencies:@react-native-async-storage/async-storage ^2.2.0. Without the version, the package manager installs async-storage 3.x, which is outside that range.
Add the provider
Pass your App ID (app_...) as appId. The prop is optional in the published types, but hosted requests fail without it: the provider logs a warning and API calls throw App ID not set. The provider initializes the SDK, restores any saved session on launch, and makes auth state available to hooks throughout your app.
Expo Router
React Native (App entry)
Verify your setup
Use theuseAuth hook to read auth state. On launch, the SDK asynchronously restores a session from the stored token; check loading before treating user === null as logged out.
Session restore errors
When a stored token cannot be validated,sessionRestoreError is set with a typed reason:
Sign in users
CallloginWithModal() to open the built-in login bottom sheet. It returns void; the modal handles email OTP verification and username registration internally.
API reference
OfflineAppProvider
useAuth()
Other hooks
Signed OfflineID credential
Version 0.3.3 exportsuseOfflineIdCredential, fetchOfflineIdCredential and fetchOfflineIdIssuerKey. These obtain an issuer-signed binding between an account, username and off1 address. The account must have a bound identity address before issuance. See credential issuance and issuer key.
Verify the signature, issuer key, address, expiry and intended account before accepting the credential. A cached credential permits offline signature verification; it does not establish current account status or replace application authorization. Issuance returns 503 when not enabled, and 409 when the account has no bound address.
The package also exports setAppId, fetchSessionFromToken and isSessionRestoreFailedError for integrations that manage session restoration directly. The built-in session provider stores its JWT unencrypted in AsyncStorage. Applications requiring platform secure storage must manage token storage and restoration explicitly; use fetchSessionFromToken to restore a session from an externally stored token. React 0.2.0 on the web has no credential hook.
Version 0.3.3 sends x-app-id. Sign-ins are attributed to the application for analytics, app membership and usage-limit enforcement. The projectId prop and setProjectId remain deprecated aliases; use appId and setAppId in new integrations.
Version 0.3.3 no longer exports useProofOfLocation or accepts locationProvider. Use the standalone @offline-protocol/pol package (0.1.2 on npm), which completes the witness exchange; see Submit a location claim.
