@offline-protocol/id-react@0.3.0 for hosted email sign-in, profiles and connections. Create an application and add the origins your site runs on, with the CLI (or the developer portal’s Domains tab):
appId prop is the application’s public identifier, not a secret key. A sign-in from an origin that is not on the list is refused with origin_not_allowed; see allowed web origins.
Add the provider and sign-in control
loginWithModal() opens the email authentication UI and returns void. Read user and loading to observe the result. Sign-in requires network access to the hosted service.
See OfflineID hooks for profile and connection APIs, or Mesh SDK identity for local device authentication.
Application attribution
For Next.js, use a public configuration value such asNEXT_PUBLIC_OFFLINE_APP_ID=app_your_application_id. Pass that value as appId.
Versions 0.2.0 and later send the App ID in x-app-id, and still send the legacy x-project-id header with the same value. Sign-ins are attributed to the application for analytics, app membership and billing pauses. Direct HTTP integrations send X-App-Id explicitly.
Upgrade from 0.2.x
sendCoderesolves totrue, and throws anOfflineIdErrorwhen the server refuses the request or does not answer. In 0.2.x it resolved tofalseand the reason was lost. Catch the error where you tested the result:
verifyCodestill resolves tonullfor a wrong or expired code, and throws anOfflineIdErrorfor any other failure (a plainErrorin 0.2.0). Its message is the server’s.- An
OfflineIdErrorcarriescode(such asorigin_not_allowed,invalid_apporcode_requests_limited;network_errorwhen no response arrived),status,message,missing,nextSteps,docs,appIdandreason. Fororigin_not_allowed,nextStepsstarts withoffline apps origins add <this page's origin>.
Upgrade from 0.1.x
- Pass
appIdtoOfflineAppProviderand callsetAppId.projectIdandsetProjectIdstill work but are deprecated. verifyCoderesolves tonullwhen the code is wrong or expired, and throws for any other failure: a network error, a timeout, an invalid email, an origin the application does not allow, a server error or a rate limit. In 0.1.x it threw in both cases.useLocationis removed. Use@offline-protocol/polfor Proof of Location.addConnectionresolves to a connection in the same shape as each item inconnections, anduseConnections()addssetLocationSharing. See OfflineID hooks.- Requests time out after 15 seconds and fail like a network error. A write that timed out may still have reached the server, so retrying it can repeat it.
- The package is licensed under MIT (0.1.5 was published as ISC).

