Overview
The Hawcx React Native SDK delivers the same Smart Connect passwordless experience that powers our native apps. The package wraps the production Hawcx iOS framework so you can orchestrate registration and login through a single JavaScript API while the Android implementation is being finalized.Smart Connect Technology
One-click intelligent authentication that automatically determines user context
Contextual Intelligence
No more “Sign Up” vs “Sign In” confusion - just one smart entry point
Seamless Cross-Platform
Smart Connect maintains user context across all devices and platforms
Enterprise-Grade Security
Production iOS cryptography and secure storage surfaced to React Native
Client-Side Simplicity
Hooks and helpers remove the need to juggle callbacks manually
Future Android Support
React integration is ready for iOS today with Android arriving shortly
Architecture
The TypeScript surface forwards every security-critical operation to the same HawcxSDK code that runs inside our native iOS app. Android bindings will share this exact architecture when released, so everything documented below applies cross-platform.
Quick Start
1
Install the SDK
- React Native (iOS)
- React Native (Android – coming soon)
- Add the package to your React Native project (pin to the latest published version):
- Declare the pod dependency in your
ios/Podfileso native builds stay in sync with the npm package:
- Install iOS pods so the bundled
HawcxFramework.xcframeworklinks correctly:
- Open the
ios/*.xcworkspacein Xcode and build once so the native module is registered. - Keep your project API key handy—you’ll pass it to
initialize()during app bootstrap.
pod install.2
Initialize Hawcx Smart Connect
- React Native (iOS)
- React Native (Android – coming soon)
bootstrapHawcx() once (e.g., inside your root provider). All subsequent API calls—authenticate, hooks, or helper clients—reuse the same native singleton.3
Implement Smart Connect authentication
Core Features
The React SDK exposes the same Smart Connect authentication flow as our native apps: a single method (
authenticate) handles login vs registration, and OTP collection happens only when the backend requires additional verification. The sections below mirror the native documentation with React-specific guidance.Smart Connect Authentication
Smart Connect Authentication
- Implementation
- React Native (iOS)
- Backend Verification (Node.js)
- React Native (Android – coming soon)
The Smart Connect bridge exposes everything you need to start a passwordless authentication flow from JavaScript:What Smart Connect Does Automatically
- Detects whether the identifier belongs to a new or existing user
- Determines if the current device is trusted or needs OTP verification
- Handles the entire Ed25519 key exchange and secure storage on the native side
- Stores access/refresh tokens inside the Secure Enclave/Keychain (not JS)
initialize(config)– configures the shared native instanceauthenticate(userId)– begins Smart Connect for a given identifiersubmitOtp(code)– forwards the 6-digit OTP when requiredaddAuthListener(listener)/useHawcxAuth()– receive OTP, success, and error eventshawcxClient.authenticate(userId, options)– promise-based helper that resolves with tokens when the flow completes
- Collect the user’s identifier (email/username).
-
Call
authenticate(userId)from React. -
When
otp_requiredfires, show OTP UI and pass the six-digit code tosubmitOtp. -
Wait for
auth_success. The payload includes the Hawcx-issued authorization code (and metadata) that must be validated server-side. -
Send the entire
auth_successpayload plus the user identifier to your backend over HTTPS. -
Your backend calls the Hawcx OAuth verification endpoint (provided via
tokenEndpoint) with itsclientIdand private credentials to exchange the code with our IDP. The IDP responds with JWTs that represent a verified Hawcx session. - Once the backend confirms the exchange succeeded, issue your own application session (cookies/tokens), notify the React app, and allow the user into protected areas.
Smart Connect removes the need to build separate “Sign Up”/“Sign In” flows. A single call handles every branch while the native layer keeps secrets off the JS heap.
OTP Handling & UI State
OTP Handling & UI State
- Implementation
- React Native (iOS)
- React Native (Android – coming soon)
- Listen to
otp_requiredevents throughuseHawcxAuthoraddAuthListener - Keep OTP UI local to React; the native layer only validates the code
- Use
hawcxClient.authenticate(userId, { onOtpRequired })when you want a promise you can await (e.g., inside Redux sagas) useHawcxAuth().reset()clears hook state so you can restart the flow without remounting components
Biometric Authentication
Biometric Authentication
- Implementation
- React Native (iOS)
- React Native (Android – coming soon)
- Use your preferred biometric library (e.g.,
react-native-biometrics) to gate access - Store the last successful Hawcx identifier in secure storage after each
auth_success - When biometrics succeed, call
hawcxClient.authenticate(lastUser)to resume Smart Connect without prompting for the identifier again - If the device was wiped or secrets were cleared, the SDK automatically falls back to OTP verification
Device Session Management
Device Session Management
- Implementation
- React Native (iOS)
- React Native (Android – coming soon)
The React SDK can fetch device metadata from the DevSession service so you can show users where they are logged in and offer local device cleanup actions.
- Call
hawcxClient.fetchDeviceDetails()to ask the native layer for current device information - Subscribe to
addSessionListenerto getsession_successorsession_errorcallbacks - Present the device list (browser, OS, timestamps) inside your security settings UI
- Clearing tokens/device keys still happens natively; expose UI toggles now so you can connect the upcoming JS helpers without redesigning screens
Troubleshooting
Smart Connect returns networkError
Smart Connect returns networkError
Symptoms:
auth_error events with networkError and the flow stops.Fixes:- Verify the device has connectivity (simulator proxies, VPNs, etc.)
- Double-check
projectApiKeyand environment overrides passed toinitialize - Implement exponential backoff when retrying
authenticate:
OTP verification fails
OTP verification fails
Symptoms: Users get stuck on the OTP screen or see
otpVerificationFailed errors.Fixes:- Limit input to 6 digits client-side (see the example above using
replace(/[^0-9]/g, '')) - Remind users that codes expire after 5 minutes—show a countdown next to the submit button
- Enable iOS OTP auto-fill by setting
textContentType="oneTimeCode"on your TextInput
Biometrics unavailable
Biometrics unavailable
State machine gets stuck
State machine gets stuck
Symptoms: The hook remains in
pending or otp even after navigating away.Fixes:- Call
reset()fromuseHawcxAuthwhen leaving the screen to clear internal counters - Remove lingering listeners created via
addAuthListenerduringuseEffectcleanup - If you manually call
hawcxClient.authenticate, keep a reference to{ cancel }so you can abort when the user backs out
Login works locally but backend sessions are missing
Login works locally but backend sessions are missing
Symptoms:
auth_success fires in React, but users never obtain a session token from your backend.Fixes:- Ensure your frontend forwards the entire
auth_successpayload to your backend before navigating away - Confirm the backend calls the Hawcx OAuth verification endpoint (
tokenEndpoint) with the client credentials we issued - Validate that the IDP response (JWTs) is stored/returned from your backend so the app can complete login
- Audit server logs for HTTP 4xx/5xx responses from the verification endpoint—most issues stem from missing or incorrect client IDs
