Skip to main content
Use @offline-protocol/id-react@0.2.0 for hosted email sign-in, profiles and connections. Create an application in the developer portal and configure its allowed web origins. The appId prop is the application’s public identifier, not a secret key. Origin checks are being rolled out; requests without an Origin header are not checked.

Add the provider and sign-in control

Supply the App ID from your environment configuration. In Next.js, keep this provider and the components using its hooks in a client component. A public App ID can be present in browser code; administrative API credentials cannot. 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 as NEXT_PUBLIC_OFFLINE_APP_ID=app_your_application_id. Pass that value as appId. Version 0.2.0 sends the App ID in x-app-id, and still sends 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.1.x

  • Pass appId to OfflineAppProvider and call setAppId. projectId and setProjectId still work but are deprecated.
  • verifyCode resolves to null when 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.
  • useLocation is removed. Use @offline-protocol/pol for Proof of Location.
  • addConnection resolves to a connection in the same shape as each item in connections, and useConnections() adds setLocationSharing. 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).