{"id":50696080,"url":"https://github.com/stytchauth/stytch-mobile","last_synced_at":"2026-06-09T06:30:37.400Z","repository":{"id":353446748,"uuid":"1119801633","full_name":"stytchauth/stytch-mobile","owner":"stytchauth","description":"Stytch is an authentication platform, written by developers for developers, with a focus on improving security and user experience via passwordless authentication","archived":false,"fork":false,"pushed_at":"2026-06-01T23:33:55.000Z","size":52861,"stargazers_count":1,"open_issues_count":4,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-02T01:18:52.563Z","etag":null,"topics":["android","authentication","ios","react-native","sdk"],"latest_commit_sha":null,"homepage":"https://stytch.com","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stytchauth.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-12-19T21:55:17.000Z","updated_at":"2026-06-01T23:33:58.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/stytchauth/stytch-mobile","commit_stats":null,"previous_names":["stytchauth/stytch-mobile"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/stytchauth/stytch-mobile","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-mobile","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-mobile/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-mobile/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-mobile/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stytchauth","download_url":"https://codeload.github.com/stytchauth/stytch-mobile/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stytchauth%2Fstytch-mobile/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34095240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","authentication","ios","react-native","sdk"],"created_at":"2026-06-09T06:30:36.705Z","updated_at":"2026-06-09T06:30:37.389Z","avatar_url":"https://github.com/stytchauth.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Stytch Mobile SDKs\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.stytch.sdk/consumer-headless?label=Maven%20Central\u0026color=blue)](https://central.sonatype.com/artifact/com.stytch.sdk/consumer-headless)\n[![npm (consumer)](https://img.shields.io/npm/v/@stytch/react-native-consumer?label=%40stytch%2Freact-native-consumer\u0026color=red)](https://www.npmjs.com/package/@stytch/react-native-consumer)\n[![npm (b2b)](https://img.shields.io/npm/v/@stytch/react-native-b2b?label=%40stytch%2Freact-native-b2b\u0026color=red)](https://www.npmjs.com/package/@stytch/react-native-b2b)\n[![CI](https://github.com/stytchauth/stytch-mobile/actions/workflows/qc.yml/badge.svg)](https://github.com/stytchauth/stytch-mobile/actions/workflows/qc.yml)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\n![Android/KMP](https://img.shields.io/badge/Android%2FKMP-API%2024%2B-3DDC84?logo=android\u0026logoColor=white)\n![iOS](https://img.shields.io/badge/iOS-15.0%2B-000000?logo=apple\u0026logoColor=white)\n![React Native](https://img.shields.io/badge/React%20Native-0.80%2B-61DAFB?logo=react\u0026logoColor=white)\n\nHeadless authentication SDKs for Android, iOS, and React Native, built on a shared [Kotlin Multiplatform](https://www.jetbrains.com/kotlin-multiplatform/) core. Bring your own UI — Stytch handles the auth.\n\n**Note**: This SDK is currently in **Public beta**. If you are instead looking for the stable version, please see [stytch-browser](https://github.com/stytchauth/stytch-browser/tree/main/packages/react-native) for React Native, [stytch-ios](https://github.com/stytchauth/stytch-ios) for iOS, and [stytch-android](https://github.com/stytchauth/stytch-android) for Android respectively.\n\n---\n\n## Consumer vs. B2B: What's Right for You?\n\n| | Consumer SDK | B2B SDK |\n|---|---|---|\n| **Use case** | B2C apps — end users authenticate directly | B2B SaaS — members authenticate within Organizations |\n| **Auth methods** | OTP, magic links, passwords, OAuth, passkeys, biometrics, TOTP, crypto wallets | OTP, magic links, passwords, OAuth, SSO (SAML/OIDC), TOTP |\n| **Additional features** | Session + user management, DFP | Organizations, members, RBAC, SCIM, discovery flows, recovery codes |\n| **Packages** | `consumer-headless` · `StytchConsumerSDK` · `@stytch/react-native-consumer` | `b2b-headless` · `StytchB2BSDK` · `@stytch/react-native-b2b` |\n\nIf you're building a consumer-facing app, you want the **Consumer SDK**. If you're building a B2B SaaS product where your customers belong to organizations, you want the **B2B SDK**. For a deeper comparison, see the [docs](https://stytch.com/docs).\n\n---\n\n## Supported Platforms\n\n| Platform | Minimum Version | Consumer | B2B |\n|---|---|---|---|\n| Android | API 24 (Android 7.0) | `com.stytch.sdk:consumer-headless` | `com.stytch.sdk:b2b-headless` |\n| iOS | 15.0 | `StytchConsumerSDK` (SPM) | `StytchB2BSDK` (SPM) |\n| React Native | 0.80.x | `@stytch/react-native-consumer` | `@stytch/react-native-b2b` |\n| JVM / Desktop | — | `com.stytch.sdk:consumer-headless` | `com.stytch.sdk:b2b-headless` |\n\n\u003e **JVM/Desktop** support is functional but limited — platform-specific features such as biometrics, OAuth, and passkeys are not available outside of the mobile platforms.\n\n---\n\n## Installation\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eAndroid\u003c/strong\u003e\u003c/summary\u003e\n\n\u0026nbsp;\n\nThe SDK requires **Kotlin 2.3.0 or later**.\n\nMake sure `mavenCentral()` is listed in your repository configuration:\n\n```kotlin\n// settings.gradle.kts\ndependencyResolutionManagement {\n    repositories {\n        mavenCentral()\n    }\n}\n```\n\nThen add the dependency to your module's `build.gradle.kts`:\n\n**Consumer**\n```kotlin\ndependencies {\n    implementation(\"com.stytch.sdk:consumer-headless:1.0.0\")\n}\n```\n\n**B2B**\n```kotlin\ndependencies {\n    implementation(\"com.stytch.sdk:b2b-headless:1.0.0\")\n}\n```\n\nPrefer callback-style APIs over coroutines? See [Callback Extensions](#callback-extensions-androidjvm) — you can swap the dependency there and get `onSuccess`/`onFailure` overloads for every method.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eiOS\u003c/strong\u003e\u003c/summary\u003e\n\n\u0026nbsp;\n\nThe iOS SDK is distributed as a Swift Package from [`stytchauth/stytch-ios-sdk`](https://github.com/stytchauth/stytch-ios-sdk).\n\n**In Xcode:**\n\n1. Go to **File → Add Package Dependencies...**\n2. Enter the repository URL: `https://github.com/stytchauth/stytch-ios-sdk`\n3. Select version **1.0.0** or later\n4. Add the product you need to your target:\n   - `StytchConsumerSDK` — Consumer apps\n   - `StytchB2BSDK` — B2B apps\n\n**In `Package.swift`:**\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/stytchauth/stytch-io-sdk\", from: \"1.0.0\"),\n],\ntargets: [\n    .target(\n        name: \"YourTarget\",\n        dependencies: [\n            // Pick one:\n            .product(name: \"StytchConsumerSDK\", package: \"stytch-ios\"),\n            // .product(name: \"StytchB2BSDK\", package: \"stytch-ios\"),\n        ]\n    ),\n]\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eReact Native\u003c/strong\u003e\u003c/summary\u003e\n\n\u0026nbsp;\n\nThe React Native packages require React Native's [New Architecture (TurboModules)](https://reactnative.dev/architecture/landing-page) and React Native **0.80.x** or later.\n\n**Consumer**\n```sh\nnpm install @stytch/react-native-consumer\n# or\nyarn add @stytch/react-native-consumer\n```\n\n**B2B**\n```sh\nnpm install @stytch/react-native-b2b\n# or\nyarn add @stytch/react-native-b2b\n```\n\n**Native code setup**\n\nIf you are using bare React Native, ensure you run `pod install` from your iOS directory. If you are using Expo, you must add the two following configurations to your app config:\n```json\n{\n    \"expo\": {\n        \"plugins\": [\n            [\n                \"expo-build-properties\",\n                {\n                    \"android\": {\n                        \"packagingOptions\": {\n                            \"exclude\": [\"META-INF/versions/9/OSGI-INF/MANIFEST.MF\"],\n                        },\n                    },\n                    \"ios\": {\n                        \"useFrameworks\": \"static\",\n                    }\n                },\n            ]\n        ]\n    }\n}\n```\n\n\u003c/details\u003e\n\n---\n\n## Quick Start\n\nThe examples below use the **Consumer SDK** with an SMS OTP login flow. The **B2B SDK** follows the same pattern — swap in `createStytchB2B` / `StytchB2BSDK` / `@stytch/react-native-b2b` and use the equivalent B2B endpoints.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eAndroid\u003c/strong\u003e\u003c/summary\u003e\n\n\u0026nbsp;\n\n**1. Initialize the client**\n\nCreate the client once — in your `Application` class or at the entry point of your auth flow. The client is a singleton; calling `createStytchConsumer` again with the same token returns the existing instance.\n\n```kotlin\nimport com.stytch.sdk.consumer.createStytchConsumer\nimport com.stytch.sdk.data.StytchClientConfiguration\n\nval stytch = createStytchConsumer(\n    StytchClientConfiguration(\n        context = applicationContext,\n        publicToken = \"public-token-live-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\",\n    )\n)\n```\n\n**2. Observe authentication state**\n\n```kotlin\nimport com.stytch.sdk.consumer.data.ConsumerAuthenticationState\n\nlifecycleScope.launch {\n    stytch.authenticationStateFlow.collect { state -\u003e\n        when (state) {\n            is ConsumerAuthenticationState.Authenticated -\u003e { /* user is logged in */ }\n            is ConsumerAuthenticationState.Unauthenticated -\u003e { /* show login UI */ }\n            is ConsumerAuthenticationState.Loading -\u003e { /* session is being restored */ }\n        }\n    }\n}\n```\n\n**3. Send and verify an SMS OTP**\n\n```kotlin\nimport com.stytch.sdk.consumer.networking.models.OTPsAuthenticateParameters\nimport com.stytch.sdk.consumer.networking.models.OTPsSMSLoginOrCreateParameters\n\n// Send OTP — creates the user if they don't exist yet\nval sendResponse = stytch.otp.sms.loginOrCreate(\n    OTPsSMSLoginOrCreateParameters(phoneNumber = \"+15551234567\")\n)\nval methodId = sendResponse.methodId\n\n// Verify the code the user entered\nval authResponse = stytch.otp.authenticate(\n    OTPsAuthenticateParameters(\n        token = userEnteredCode,\n        methodId = methodId,\n        sessionDurationMinutes = 30,\n    )\n)\n```\n\nAll SDK methods are `suspend` functions — call them from a coroutine scope (`viewModelScope`, `lifecycleScope`, etc.). Errors are thrown as `StytchError`.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eiOS\u003c/strong\u003e\u003c/summary\u003e\n\n\u0026nbsp;\n\n**1. Initialize the client**\n\n```swift\nimport StytchConsumerSDK\n\nlet stytch = createStytchConsumer(\n    configuration: .init(\n        publicToken: \"public-token-live-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"\n    )\n)\n```\n\n**2. Observe authentication state**\n\n```swift\nTask {\n    for await state in stytch.authenticationStateFlow {\n        switch onEnum(of: state) {\n        case .authenticated(let s):\n            print(\"Logged in: \\(s.user)\")\n        case .unauthenticated:\n            print(\"Not logged in\")\n        case .loading:\n            print(\"Loading...\")\n        }\n    }\n}\n```\n\n**3. Send and verify an SMS OTP**\n\n```swift\n// Send OTP — creates the user if they don't exist yet\nlet sendParams: OTPsSMSLoginOrCreateParameters = .init(phoneNumber: \"+15551234567\")\nlet sendResponse = try await stytch.otp.sms.loginOrCreate(request: sendParams)\nlet methodId = sendResponse.methodId\n\n// Verify the code the user entered\nlet authParams: OTPsAuthenticateParameters = .init(\n    token: userEnteredCode,\n    methodId: methodId,\n    sessionDurationMinutes: 30\n)\nlet authResponse = try await stytch.otp.authenticate(request: authParams)\n```\n\nAll SDK methods are `async throws`. Errors are thrown as `StytchError`.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eReact Native\u003c/strong\u003e\u003c/summary\u003e\n\n\u0026nbsp;\n\n**1. Initialize the client and wrap your app**\n\n```tsx\nimport {\n    createStytchConsumer,\n    StytchClientConfiguration,\n    StytchProvider,\n} from '@stytch/react-native-consumer';\n\nconst stytch = createStytchConsumer(\n    new StytchClientConfiguration(\"public-token-live-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\")\n);\n\nexport default function App() {\n    return (\n        \u003cStytchProvider stytch={stytch}\u003e\n            \u003cYourNavigator /\u003e\n        \u003c/StytchProvider\u003e\n    );\n}\n```\n\n**2. Access the client and state in components**\n\n```tsx\nimport { useStytch, useStytchUser, useStytchSession } from '@stytch/react-native-consumer';\n\nfunction ProfileHeader() {\n    const user = useStytchUser();\n    const session = useStytchSession();\n    return (\n        \u003cText\u003e{user ? `Logged in as ${user.emails[0]?.email}` : 'Not logged in'}\u003c/Text\u003e\n    );\n}\n```\n\n**3. Send and verify an SMS OTP**\n\n```tsx\nimport { useStytch } from '@stytch/react-native-consumer';\n\nfunction SmsOtpScreen() {\n    const stytch = useStytch();\n    const [methodId, setMethodId] = useState\u003cstring | null\u003e(null);\n\n    const sendOtp = async (phoneNumber: string) =\u003e {\n        const response = await stytch.otp.sms.loginOrCreate({ phoneNumber });\n        setMethodId(response.methodId);\n    };\n\n    const verifyOtp = async (code: string) =\u003e {\n        await stytch.otp.authenticate({\n            token: code,\n            methodId: methodId!,\n            sessionDurationMinutes: 30,\n        });\n    };\n\n    // ...\n}\n```\n\n\u003c/details\u003e\n\n---\n\n## Callback Extensions (Android/JVM)\n\nBy default, all SDK methods are Kotlin `suspend` functions. If your project uses callback-style APIs — or you're calling the SDK from Java — the `*-headless-extensions` artifacts provide `onSuccess`/`onFailure` overloads for every method, returning a cancellable `Job`:\n\n```kotlin\n// Coroutine style (base SDK):\nval result = stytch.otp.authenticate(params)\n\n// Callback style (extensions):\nval job = stytch.otp.authenticate(\n    request = params,\n    onSuccess = { response -\u003e /* handle success */ },\n    onFailure = { error -\u003e /* handle error */ },\n)\n```\n\nTo use the callback extensions, swap the base dependency for the extensions artifact — it re-exports the base module, so no other changes are needed:\n\n```kotlin\n// Before:\nimplementation(\"com.stytch.sdk:consumer-headless:1.0.0\")\n\n// After:\nimplementation(\"com.stytch.sdk:consumer-headless-extensions:1.0.0\")\n\n// Same for B2B:\nimplementation(\"com.stytch.sdk:b2b-headless-extensions:1.0.0\")\n```\n\nCallback extensions are available on Android and JVM only. iOS uses native `async/await` and React Native handles async natively in JavaScript.\n\n---\n\n## Documentation\n\nFull API documentation is included (KDoc/JavaDoc, DocC, JSDoc) for in-editor reference, as well as hosted [here](https://stytchauth.github.io/stytch-mobile/).\n\nFor deeper documentation, consult our [docs site](https://stytch.com/docs).\n\n## Support\n\nIf you have questions, found a bug or want help troubleshooting, join us in [Slack](https://stytch.com/docs/resources/support/overview) or email [support@stytch.com](mailto:support@stytch.com).\n\nIf you've found a security vulnerability, please follow our [responsible disclosure instructions](https://stytch.com/docs/resources/security-and-trust/security#:~:text=Responsible%20disclosure%20program).\n\n## Contributing\n\nWe welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details on how to submit issues, pull requests, and contribute to the project.\n\n## Development\n\nSee [DEVELOPMENT.md](DEVELOPMENT.md)\n\n## Security\n\nIf you discover a security vulnerability, please report it to us at `security@stytch.com`. See our [Security Policy](SECURITY.md) for more details.\n\n## Code of Conduct\n\nEveryone interacting in Stytch codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-mobile","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstytchauth%2Fstytch-mobile","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstytchauth%2Fstytch-mobile/lists"}