Better Auth Support for React Native CLI (no Expo) #1397

Closed
opened 2026-03-13 08:37:37 -05:00 by GiteaMirror · 14 comments
Owner

Originally created by @sujayxaradhya on GitHub (Jun 21, 2025).

I am searching through internet to find a way to use Better Auth in React Native CLI but got no luck.
I have used Better Auth in many React projects but this time I eagerly want to use it in my React Native CLI (bare React Native) project without Expo.

I don't use Expo and I'm not familiar with it because I don't want to use Expo.

Is there any workaround to achieve Better-Auth in React Native CLI? As Better-Auth is the best Auth library I've ever used in my life.

Originally created by @sujayxaradhya on GitHub (Jun 21, 2025). I am searching through internet to find a way to use Better Auth in React Native CLI but got no luck. I have used Better Auth in many React projects but this time I eagerly want to use it in my React Native CLI (bare React Native) project without Expo. I don't use Expo and I'm not familiar with it because I don't want to use Expo. Is there any workaround to achieve Better-Auth in React Native CLI? As Better-Auth is the best Auth library I've ever used in my life.
Author
Owner

@sujayxaradhya commented on GitHub (Jun 21, 2025):

Please help @Bekacru

@sujayxaradhya commented on GitHub (Jun 21, 2025): Please help @Bekacru
Author
Owner

@dosubot[bot] commented on GitHub (Jun 21, 2025):

Better Auth doesn't currently support React Native CLI (bare React Native, no Expo), and there aren't any official or community workarounds documented for this setup. The main blockers are dependencies on Expo-specific modules (like expo-crypto, expo-linking, expo-secure-store) and browser APIs, which aren't available in bare React Native projects. If you're comfortable with advanced setup, you could try adapting the web or Expo client code by replacing incompatible modules and handling deep linking and secure storage yourself, but this would require significant custom work and isn't officially supported or documented right now. If you need a smoother integration today, you might want to look into authentication libraries built specifically for React Native CLI. If you have a specific use case or requirements, sharing those could help inform future support or community solutions.

References:

Written by @dosu, approved by Bekacru

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 21, 2025): <!-- Answer --> Better Auth doesn't currently support React Native CLI (bare React Native, no Expo), and there aren't any official or community workarounds documented for this setup. The main blockers are dependencies on Expo-specific modules (like expo-crypto, expo-linking, expo-secure-store) and browser APIs, which aren't available in bare React Native projects. If you're comfortable with advanced setup, you could try adapting the web or Expo client code by replacing incompatible modules and handling deep linking and secure storage yourself, but this would require significant custom work and isn't officially supported or documented right now. If you need a smoother integration today, you might want to look into authentication libraries built specifically for React Native CLI. If you have a specific use case or requirements, sharing those could help inform future support or community solutions. References: - [Expo-specific dependencies in Better Auth](https://github.com/better-auth/better-auth/blob/08d92952ab827d6201fe756f4c8d4d921471c0d9/packages/expo/package.json) - [Expo implementation details](https://github.com/better-auth/better-auth/blob/08d92952ab827d6201fe756f4c8d4d921471c0d9/packages/expo/src/index.ts) _Written by @dosu, approved by Bekacru_ <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/16a5b740-0c4f-47a1-b178-e348ab9c1417?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/16a5b740-0c4f-47a1-b178-e348ab9c1417?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/16a5b740-0c4f-47a1-b178-e348ab9c1417?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/16a5b740-0c4f-47a1-b178-e348ab9c1417?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/16a5b740-0c4f-47a1-b178-e348ab9c1417?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/16a5b740-0c4f-47a1-b178-e348ab9c1417?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/16a5b740-0c4f-47a1-b178-e348ab9c1417?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3120)
Author
Owner

@sujayxaradhya commented on GitHub (Jun 21, 2025):

Thanks for guidance. I can fully trust on Better-Auth and all of the maintainers. Please recommend some resource that I can use and is open source.
@dosu If you could recommend any resource that I can use, would really be appreciated.
Looking forward to your reply!

Thank You!

Best,
Sujay

@sujayxaradhya commented on GitHub (Jun 21, 2025): Thanks for guidance. I can fully trust on Better-Auth and all of the maintainers. Please recommend some resource that I can use and is open source. @dosu If you could recommend any resource that I can use, would really be appreciated. Looking forward to your reply! Thank You! Best, Sujay
Author
Owner

@dosubot[bot] commented on GitHub (Jun 21, 2025):

There aren’t any official or community resources for using Better Auth with React Native CLI (bare, no Expo), and the main blockers are dependencies on Expo modules and browser APIs that aren’t available in bare React Native projects. The Better Auth codebase is plugin-based, so in theory, an advanced user could adapt it by writing a custom plugin to handle deep linking and secure storage using React Native-compatible modules, but there’s no guide or example for this yet.

For production-ready authentication in React Native CLI, most teams use libraries like:

You’ll find many guides and starter projects for these libraries—search for “react-native-app-auth example” or “react-native-firebase auth starter” for up-to-date tutorials.

If you want to experiment with adapting Better Auth, the Expo client code is the best reference: you’d need to swap out all Expo-specific modules (like expo-linking, expo-web-browser, expo-secure-store) for their React Native equivalents, and implement deep linking and secure storage yourself. The plugin system is flexible, but this would be an advanced, custom integration.

If you have a specific provider or flow in mind (OAuth, social login, etc.), let me know and I can point you to more targeted resources!

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 21, 2025): <!-- Answer --> There aren’t any official or community resources for using Better Auth with React Native CLI (bare, no Expo), and the main blockers are dependencies on Expo modules and browser APIs that aren’t available in bare React Native projects. The Better Auth codebase is plugin-based, so in theory, an advanced user could adapt it by writing a custom plugin to handle deep linking and secure storage using React Native-compatible modules, but there’s no guide or example for this yet. For production-ready authentication in React Native CLI, most teams use libraries like: - [react-native-app-auth](https://github.com/FormidableLabs/react-native-app-auth) (OAuth 2.0/OpenID Connect, supports PKCE) - [react-native-firebase/auth](https://rnfirebase.io/auth/usage) (Firebase Auth, supports social providers and email/password) - [react-native-auth0](https://github.com/auth0/react-native-auth0) (Auth0 SDK for React Native) You’ll find many guides and starter projects for these libraries—search for “react-native-app-auth example” or “react-native-firebase auth starter” for up-to-date tutorials. If you want to experiment with adapting Better Auth, the Expo client code is the best reference: you’d need to swap out all Expo-specific modules (like expo-linking, expo-web-browser, expo-secure-store) for their React Native equivalents, and implement deep linking and secure storage yourself. The plugin system is flexible, but this would be an advanced, custom integration. If you have a specific provider or flow in mind (OAuth, social login, etc.), let me know and I can point you to more targeted resources! <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/cfb5514b-4ea3-42f8-a2a0-6949814d5368?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/cfb5514b-4ea3-42f8-a2a0-6949814d5368?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/cfb5514b-4ea3-42f8-a2a0-6949814d5368?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/cfb5514b-4ea3-42f8-a2a0-6949814d5368?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/cfb5514b-4ea3-42f8-a2a0-6949814d5368?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/cfb5514b-4ea3-42f8-a2a0-6949814d5368?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/cfb5514b-4ea3-42f8-a2a0-6949814d5368?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3120)
Author
Owner

@sujayxaradhya commented on GitHub (Jun 21, 2025):

@dosu I want to use Better Auth with React Native CLI. How can I achieve that? If I follow this approach -
"The Better Auth codebase is plugin-based, so in theory, an advanced user could adapt it by writing a custom plugin to handle deep linking and secure storage using React Native-compatible modules, but there’s no guide or example for this yet."
Please help and guide me in that!

@sujayxaradhya commented on GitHub (Jun 21, 2025): @dosu I want to use Better Auth with React Native CLI. How can I achieve that? If I follow this approach - "The Better Auth codebase is plugin-based, so in theory, an advanced user could adapt it by writing a custom plugin to handle deep linking and secure storage using React Native-compatible modules, but there’s no guide or example for this yet." Please help and guide me in that!
Author
Owner

@dosubot[bot] commented on GitHub (Jun 21, 2025):

There’s no official support or ready-made guide for using Better Auth with React Native CLI (bare, no Expo), but it’s technically possible for an advanced user to create a custom client plugin. Here’s how you’d approach it:

  1. Understand the plugin system: Better Auth’s client is extensible via plugins. You’d create a plugin that implements the BetterAuthClientPlugin interface, similar to the Expo plugin, but using React Native-compatible modules for deep linking and secure storage. See the interface definition and examples and plugin docs.

  2. Replace Expo modules:

  3. Reference the Expo plugin: The Expo plugin code shows how deep linking, browser sessions, and secure storage are handled. You’d need to swap out all Expo-specific calls for the React Native equivalents.

  4. Implement your plugin:

    • Implement getActions for custom auth actions (like opening the browser for OAuth, handling redirects, etc).
    • Implement getAtoms if you want to expose state for hooks.
    • Use fetchPlugins if you need to customize network requests (e.g., to add headers or handle cookies).
    • Handle deep link callbacks by listening for URL events and passing tokens/cookies as needed.
  5. Register your plugin: Pass your plugin to the plugins array when creating the auth client.

Caveats:

  • You’ll need to manually handle OAuth redirects and token storage.
  • Some browser APIs used by Better Auth’s web client may not be available in React Native CLI, so you may need to polyfill or adapt those parts.
  • There are no existing examples or community plugins for this, so you’ll be breaking new ground.

If you want to see how other plugins are structured, check out the test plugin or generic OAuth plugin.

If you get stuck on a specific part (like deep linking or secure storage), let me know what you’re trying to do and I can help with more targeted guidance.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Join Discord Share on X

@dosubot[bot] commented on GitHub (Jun 21, 2025): <!-- Answer --> There’s no official support or ready-made guide for using Better Auth with React Native CLI (bare, no Expo), but it’s technically possible for an advanced user to create a custom client plugin. Here’s how you’d approach it: 1. **Understand the plugin system:** Better Auth’s client is extensible via plugins. You’d create a plugin that implements the `BetterAuthClientPlugin` interface, similar to the Expo plugin, but using React Native-compatible modules for deep linking and secure storage. See the [interface definition and examples](https://github.com/better-auth/better-auth/blob/2fe1be0e5f023be77b07206dd960f9fd38abba8c/packages/better-auth/src/client/types.ts) and [plugin docs](https://github.com/better-auth/better-auth/blob/2fe1be0e5f023be77b07206dd960f9fd38abba8c/docs/content/docs/concepts/plugins.mdx). 2. **Replace Expo modules:** - For deep linking, use React Native’s built-in [`Linking`](https://reactnative.dev/docs/linking) API. - For secure storage, use [`react-native-keychain`](https://github.com/oblador/react-native-keychain) or [`@react-native-async-storage/async-storage`](https://github.com/react-native-async-storage/async-storage). - For in-app browser OAuth flows, use [`react-native-inappbrowser-reborn`](https://github.com/proyecto26/react-native-inappbrowser) or similar. 3. **Reference the Expo plugin:** The [Expo plugin code](https://github.com/better-auth/better-auth/blob/2fe1be0e5f023be77b07206dd960f9fd38abba8c/packages/expo/src/index.ts) shows how deep linking, browser sessions, and secure storage are handled. You’d need to swap out all Expo-specific calls for the React Native equivalents. 4. **Implement your plugin:** - Implement `getActions` for custom auth actions (like opening the browser for OAuth, handling redirects, etc). - Implement `getAtoms` if you want to expose state for hooks. - Use `fetchPlugins` if you need to customize network requests (e.g., to add headers or handle cookies). - Handle deep link callbacks by listening for URL events and passing tokens/cookies as needed. 5. **Register your plugin:** Pass your plugin to the `plugins` array when creating the auth client. **Caveats:** - You’ll need to manually handle OAuth redirects and token storage. - Some browser APIs used by Better Auth’s web client may not be available in React Native CLI, so you may need to polyfill or adapt those parts. - There are no existing examples or community plugins for this, so you’ll be breaking new ground. If you want to see how other plugins are structured, check out the [test plugin](https://github.com/better-auth/better-auth/blob/2fe1be0e5f023be77b07206dd960f9fd38abba8c/packages/better-auth/src/client/test-plugin.ts) or [generic OAuth plugin](https://github.com/better-auth/better-auth/pull/149). If you get stuck on a specific part (like deep linking or secure storage), let me know what you’re trying to do and I can help with more targeted guidance. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/b218889c-c437-4cae-9091-9bcec27c465d?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/b218889c-c437-4cae-9091-9bcec27c465d?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/b218889c-c437-4cae-9091-9bcec27c465d?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/b218889c-c437-4cae-9091-9bcec27c465d?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/b218889c-c437-4cae-9091-9bcec27c465d?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/b218889c-c437-4cae-9091-9bcec27c465d?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/b218889c-c437-4cae-9091-9bcec27c465d?feedback_type=other)</sup>&nbsp;&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/3120)
Author
Owner

@VikashLoomba commented on GitHub (Aug 1, 2025):

+1 to getting better-auth working without an explicit dependency on expo.

@VikashLoomba commented on GitHub (Aug 1, 2025): +1 to getting better-auth working without an explicit dependency on expo.
Author
Owner

@sujayxaradhya commented on GitHub (Aug 1, 2025):

+1 to getting better-auth working without an explicit dependency on expo.

Exactly, looking for the same but I have found a workaround.

@sujayxaradhya commented on GitHub (Aug 1, 2025): > +1 to getting better-auth working without an explicit dependency on expo. Exactly, looking for the same but I have found a workaround.
Author
Owner

@VikashLoomba commented on GitHub (Aug 2, 2025):

+1 to getting better-auth working without an explicit dependency on expo.

Exactly, looking for the same but I have found a workaround.

Please share!!

@VikashLoomba commented on GitHub (Aug 2, 2025): > > +1 to getting better-auth working without an explicit dependency on expo. > > Exactly, looking for the same but I have found a workaround. Please share!!
Author
Owner

@hrithiqball commented on GitHub (Aug 17, 2025):

+1 to getting better-auth working without an explicit dependency on expo.

Exactly, looking for the same but I have found a workaround.

please share we are working on this right now

@hrithiqball commented on GitHub (Aug 17, 2025): > > +1 to getting better-auth working without an explicit dependency on expo. > > Exactly, looking for the same but I have found a workaround. please share we are working on this right now
Author
Owner

@sujayxaradhya commented on GitHub (Aug 17, 2025):

+1 to getting better-auth working without an explicit dependency on expo.

Exactly, looking for the same but I have found a workaround.

please share we are working on this right now

Sure, can you tell me what workaround you guys have right now?

@sujayxaradhya commented on GitHub (Aug 17, 2025): > > > +1 to getting better-auth working without an explicit dependency on expo. > > > > Exactly, looking for the same but I have found a workaround. > > please share we are working on this right now Sure, can you tell me what workaround you guys have right now?
Author
Owner

@hrithiqball commented on GitHub (Aug 17, 2025):

@sujayxaradhya i activated bearer and jwt for now. it gives a valid bearer token but the session is not so long. i still can't figure out how to refresh the session

@hrithiqball commented on GitHub (Aug 17, 2025): @sujayxaradhya i activated bearer and jwt for now. it gives a valid bearer token but the session is not so long. i still can't figure out how to refresh the session
Author
Owner

@sujayxaradhya commented on GitHub (Aug 17, 2025):

@hrithiqball @VikashLoomba Guys, workaround is simple. We just have to call the auth api endpoints on the app as we do with other libraries like passportjs and all. I was also influenced with bearer and jwt mechanism but now my priority is Session and Cookies based auth because it is more secure and performant than bearer and jwt.

I was also stuck in the loop of verifying and refreshing session which is way harder to make it work when I was using Passportjs. You can find out the discussions about jwt bearer vs session with cookie auth in the active communities. You will end up getting session and cookie based auth is best. Although, this is very controversial topic and do your research about this.

Still above is the advice and you have to make your own call according to your use case.

@sujayxaradhya commented on GitHub (Aug 17, 2025): @hrithiqball @VikashLoomba Guys, workaround is simple. We just have to call the auth api endpoints on the app as we do with other libraries like passportjs and all. I was also influenced with bearer and jwt mechanism but now my priority is Session and Cookies based auth because it is more secure and performant than bearer and jwt. I was also stuck in the loop of verifying and refreshing session which is way harder to make it work when I was using Passportjs. You can find out the discussions about jwt bearer vs session with cookie auth in the active communities. You will end up getting session and cookie based auth is best. Although, this is very controversial topic and do your research about this. Still above is the advice and you have to make your own call according to your use case.
Author
Owner

@dosubot[bot] commented on GitHub (Nov 16, 2025):

Hi, @sujayxaradhya. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You inquired about using Better Auth in a bare React Native CLI project without Expo.
  • It was clarified that Better Auth currently relies on Expo modules and browser APIs, so no official support or documented workarounds exist for bare React Native.
  • Guidance was provided on creating a custom plugin to replace Expo dependencies with React Native equivalents like Linking and react-native-keychain.
  • You shared a workaround involving direct calls to auth API endpoints and discussed session/cookie-based auth versus bearer/JWT tokens.
  • The issue remains unresolved with interest from other users in non-Expo support.

Next Steps:

  • Please let me know if this issue is still relevant to the latest version of better-auth by commenting here.
  • If I do not hear back within 7 days, this issue will be automatically closed.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Nov 16, 2025): Hi, @sujayxaradhya. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You inquired about using Better Auth in a bare React Native CLI project without Expo. - It was clarified that Better Auth currently relies on Expo modules and browser APIs, so no official support or documented workarounds exist for bare React Native. - Guidance was provided on creating a custom plugin to replace Expo dependencies with React Native equivalents like Linking and react-native-keychain. - You shared a workaround involving direct calls to auth API endpoints and discussed session/cookie-based auth versus bearer/JWT tokens. - The issue remains unresolved with interest from other users in non-Expo support. **Next Steps:** - Please let me know if this issue is still relevant to the latest version of better-auth by commenting here. - If I do not hear back within 7 days, this issue will be automatically closed. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#1397