React Native SDK
@quickauth/react-native — one JS API with native modules for Android SMS Retriever and iOS one-time-code under the hood. Pre-built components or fully headless, your call.
Requirements
- React Native 0.72+
- iOS 12.0+, Xcode 14+
- Android minSdk 21 (Lollipop)
Install
npm install @quickauth/react-nativeiOS: run cd ios && pod install from your app root.
Android: autolinking handles it. If you’ve disabled autolinking, register QuickAuthSdkPackage in your MainApplication.java.
Initialize
// App.tsx — call once near the entrypoint
import QuickAuth from '@quickauth/react-native'
await QuickAuth.init({
// Returns a fresh session JWT from your backend.
onTokenExpiry: async () =>
(await fetch('/api/quickauth-token').then(r => r.json())).sessionToken,
// Single typed event stream — all OTP / OneTap outcomes flow through here.
onAuthEvent: (event) => {
switch (event.type) {
case 'OTP_SENT': showOtpInput(); break
case 'OTP_AUTO_READ': prefillInput(event.code); break
case 'VERIFIED': finishLogin(event.requestId); break
case 'OTP_FAILED': showError(event.message); break
case 'ERROR': showError(event.message); break
}
},
})Consent
await QuickAuth.consent.set(true)
const granted = await QuickAuth.consent.get()Headless flow
Two methods. initiate kicks off the auth attempt; submitOtp hands back the user-typed code. All outcomes arrive on the onAuthEvent handler — including the OneTap silent re-auth path, where the backend emits VERIFIED directly without sending an SMS.
import QuickAuth, { OtpChannel } from '@quickauth/react-native'
// Step 1 — kick off the attempt. Events arrive via onAuthEvent.
await QuickAuth.auth.initiate({
phone: '+919876543210',
channel: OtpChannel.AUTO,
})
// → onAuthEvent fires with one of:
// { type: 'OTP_SENT', sessionId, channel, expiresIn }
// { type: 'VERIFIED', requestId } // OneTap fired
// { type: 'ERROR', code, message }
// Step 2 — when OTP_SENT fires and the user types a code:
await QuickAuth.auth.submitOtp('123456')
// → onAuthEvent fires with VERIFIED / OTP_FAILED / ERROR
// On user-initiated logout, drop the OneTap trust token:
await QuickAuth.auth.reset({ forgetDevice: true })Pre-built UI
Two components ship in the box — a single login button that handles the whole flow, and a styled OTP-input field if you want to roll your own UI but keep the auto-fill plumbing.
import { QuickAuthLoginButton } from '@quickauth/react-native'
function Login() {
return (
<QuickAuthLoginButton
phone="+919876543210"
onSuccess={(jwt) => saveJwt(jwt)}
onError={(err) => console.error(err)}
/>
)
}Android SMS Retriever
On Android, the SDK uses Google Play Services SMS Retriever — no RECEIVE_SMS permission, no permission prompt to the user. Your outbound OTP body must include the 11-char app hash; QuickAuth backend handles that automatically once you’ve uploaded your release SHA-256.
Attribution
// Capture on cold launch (in useEffect of your root component).
await QuickAuth.attribution.captureLaunch()
// Track a conversion event later:
await QuickAuth.attribution.trackConversion({
event: 'signup',
value: 0,
currency: 'INR',
})API reference
| Method | Description |
|---|---|
init(config) | Initialize the SDK. |
consent.set / get | DPDP / GDPR consent gate. |
auth.initiate({ phone, channel }) | Begin an auth attempt. Emits OTP_SENT or VERIFIED. |
auth.submitOtp(code) | Submit the user-typed code. Emits VERIFIED or OTP_FAILED. |
auth.reset({ forgetDevice }) | Reset the state machine. Pass forgetDevice: true on logout. |
auth.startWhatsAppLogin | Start WhatsApp OTP verification. |
QuickAuthLoginButton | Drop-in button component. |
QuickAuthOtpField | Styled OTP input with auto-fill. |
attribution.captureLaunch / trackConversion | Attribution and conversion tracking. |
Source & changelog
Source: github.com/quickauthin/quickauth-sdk-react-native. Package: @quickauth/react-native on npm.