API Documentation
/
Frontend
/
React Native
/
Hawcx React Native SDK with Smart Connect

Hawcx React Native SDK with Smart Connect

Bring Hawcx Smart Connect to React Native using our production iOS and Android SDKs.

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 and Android frameworks so you can orchestrate registration and login through a single JavaScript API.

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

Unified Native SDKs

The React bridge delegates to the same production Swift and Kotlin SDKs that power our mobile apps

Architecture

Loading diagram...

The TypeScript surface forwards every security-critical operation to the same HawcxSDK code that runs inside our production iOS and Android apps.

Quick Start

  1. Add the package to your React Native project (pin to the latest published version):
npm install @hawcx/[email protected]
  1. Install iOS pods so the bundled HawcxFramework.xcframework links correctly:
cd ios && pod install
  1. Open the ios/*.xcworkspace in Xcode and build once so the native module is registered.
  2. Keep your project API key and tenant base URL handy - you will pass both to initialize() during app bootstrap. The base URL is the host we provisioned for your environment (example: https://hawcx-api.hawcx.com). Do not append /hc_auth; the native SDK adds all endpoint paths automatically.

The Podspec included in the package automatically embeds the latest Hawcx framework; no manual Podfile edits are required.

  1. Install the package: npm install @hawcx/[email protected].
  2. Ensure your Android project targets minSdkVersion 26 or higher.
  3. Add the Hawcx Maven repository so Gradle can resolve the native SDK dependency:
android/settings.gradle(.kts)
dependencyResolutionManagement {
  repositories {
    google()
    mavenCentral()
    maven {
      url = uri("https://raw.githubusercontent.com/hawcx/hawcx_android_sdk/main/maven")
      metadataSources {
        mavenPom()
        artifact()
      }
    }
  }
}

If your project still uses android/build.gradle repositories, add the same Maven block there instead.

The hosted Maven repo is public - no GitHub token is required. If you mirror the artifacts internally, point these blocks at your own URL instead.

  1. Remove legacy local AAR wiring if present (android/libs/hawcx-*.aar or flatDir { dirs 'libs' }). The React Native module already declares the api.hawcx dependency for you.
  2. Sync/clean once so Gradle resolves the dependency:
cd android && ./gradlew clean assembleDebug --refresh-dependencies
  1. Rebuild with npm run android (or Android Studio). React Native autolinking registers the Kotlin module automatically - no manual edits to MainApplication are needed.
  2. Keep the same Hawcx project API key and tenant base URL available; the TypeScript initialization call is identical on Android.
import { initialize, addAuthListener } from '@hawcx/react-native-sdk';

export async function bootstrapHawcx() {
  await initialize({
    projectApiKey: 'YOUR_API_KEY',
    baseUrl: 'https://your-tenant.hawcx-api.hawcx.com',
  });

  const subscription = addAuthListener((event) => {
    if (event.type === 'auth_error') {
      console.warn('Hawcx error', event.payload);
    }
  });

  return () => subscription.remove();
}

Call bootstrapHawcx() once (for example, inside your root provider). All subsequent API calls - authenticate, hooks, or helper clients - reuse the same native singleton.

baseUrl must be the scheme + host that Hawcx provisioned for your tenant (for example https://hawcx-api.hawcx.com).

Do not pass OAuth client credentials to initialize. Those values belong on your backend only; the mobile SDK should receive authorization codes and forward them for verification.

The same initialization code runs on Android. The Kotlin bridge proxies every call to the Hawcx Android SDK, so call initialize() once during app bootstrap (e.g., inside your root component or Redux saga), passing the same projectApiKey + baseUrl.

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.

Troubleshooting