[GH-ISSUE #6930] Integration with Capacitor #27998

Open
opened 2026-04-17 19:19:21 -05:00 by GiteaMirror · 2 comments
Owner

Originally created by @mahyarmirrashed on GitHub (Dec 22, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/6930

Is this suited for github?

  • Yes, this is suited for github

Yes, I am trying to build a Svelte app with Capacitor. I am currently able to start the OAuth flow from Capacitor (it launches a browser tab), I complete the sign in, and it sends me to my domain, https://mydomain.com. It sets the cookies that I need there. It is only after that, though, that the deep linking kicks in to take me back into my app. Security policies in Apple and Android do not allow reading cookies from outside the deep linked app. So, how can we do OAuth flow with Better Auth in this case?

Describe the solution you'd like

I just want it to work, with minimal configuration.

Describe alternatives you've considered

I considered (never implemented) a solution where Better Auth returns the session_token and state cookies as query params, they get sent to my app via the deep linking, and I can register a Better Auth handler in my app that grabs those from the URL params. However, that is pretty insecure.

Honestly, I have no idea what is a good way to do this. I just want it to be possible.

Additional context

No response

Originally created by @mahyarmirrashed on GitHub (Dec 22, 2025). Original GitHub issue: https://github.com/better-auth/better-auth/issues/6930 ### Is this suited for github? - [x] Yes, this is suited for github ### Is your feature request related to a problem? Please describe. Yes, I am trying to build a Svelte app with Capacitor. I am currently able to start the OAuth flow from Capacitor (it launches a browser tab), I complete the sign in, and it sends me to my domain, `https://mydomain.com`. It sets the cookies that I need there. It is only after that, though, that the deep linking kicks in to take me back into my app. Security policies in Apple and Android do not allow reading cookies from outside the deep linked app. So, how can we do OAuth flow with Better Auth in this case? ### Describe the solution you'd like I just want it to work, with minimal configuration. ### Describe alternatives you've considered I considered (never implemented) a solution where Better Auth returns the session_token and state cookies as query params, they get sent to my app via the deep linking, and I can register a Better Auth handler in my app that grabs those from the URL params. However, that is pretty insecure. Honestly, I have no idea what is a good way to do this. I just want it to be possible. ### Additional context _No response_
GiteaMirror added the platformoauth labels 2026-04-17 19:19:21 -05:00
Author
Owner

@better-auth-agent[bot] commented on GitHub (Dec 22, 2025):

To address the integration of Better Auth with Capacitor for handling the OAuth flow, you may consider the following steps:

  1. Deep Linking Configuration: Ensure that your Capacitor app is set up to handle deep links. You need to define a URL scheme in your app’s configuration to allow Better Auth to redirect back to your app after login. This configuration can typically be found in your capacitor.config.json or content of the appropriate native project files.

  2. Using Cookies in Capacitor: Since security policies of Apple and Android prevent reading cookies from outside the deep-linked app, consider utilizing the integration options that Better Auth provides. This may involve configuring Better Auth to send the session tokens as part of the URL params in a secure way rather than relying on cookies.

  3. Possible Plugin Usage: Verify if there’s a specific Better Auth or Capacitor plugin that addresses this issue, as other implementations may have documented their approaches to similar problems, particularly with OAuth flows.

  4. Consult the Community: If the above solutions do not address your issue, I suggest tagging @bekacru and @ping__ in your query. They have experience with Better Auth and may offer insights tailored to your specific needs.

Do you have any specific questions or details you need help with in this integration?

If you need more help, tag @better-auth-agent in a comment so I can respond.

DiagramDiscordGitHub

Diagram Join Star

<!-- gh-comment-id:3680874016 --> @better-auth-agent[bot] commented on GitHub (Dec 22, 2025): To address the integration of Better Auth with Capacitor for handling the OAuth flow, you may consider the following steps: 1. **Deep Linking Configuration**: Ensure that your Capacitor app is set up to handle deep links. You need to define a URL scheme in your app’s configuration to allow Better Auth to redirect back to your app after login. This configuration can typically be found in your `capacitor.config.json` or content of the appropriate native project files. 2. **Using Cookies in Capacitor**: Since security policies of Apple and Android prevent reading cookies from outside the deep-linked app, consider utilizing the integration options that Better Auth provides. This may involve configuring Better Auth to send the session tokens as part of the URL params in a secure way rather than relying on cookies. 3. **Possible Plugin Usage**: Verify if there’s a specific Better Auth or Capacitor plugin that addresses this issue, as other implementations may have documented their approaches to similar problems, particularly with OAuth flows. 4. **Consult the Community**: If the above solutions do not address your issue, I suggest tagging @bekacru and @ping__ in your query. They have experience with Better Auth and may offer insights tailored to your specific needs. Do you have any specific questions or details you need help with in this integration? _If you need more help, tag @better-auth-agent in a comment so I can respond._ <!-- bot:webhook reply v1 --> [Diagram](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) • [Discord](https://discord.gg/fG2XXEuQX3) • [GitHub](https://github.com/Skyvern-AI/Skyvern) [![Diagram](https://img.shields.io/badge/Diagram-2b3137?style=flat-square)](https://repodiagrams.s3.eu-north-1.amazonaws.com/skyvern_ultra_detailed_interactive.html) [![Join](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&style=flat-square)](https://discord.gg/fG2XXEuQX3) [![Star](https://img.shields.io/badge/star-181717?logo=github&logoColor=white&style=flat-square)](https://github.com/Skyvern-AI/Skyvern)
Author
Owner

@productdevbook commented on GitHub (Jan 29, 2026):

better-auth-capacitor I published a library related to this.

<!-- gh-comment-id:3815752130 --> @productdevbook commented on GitHub (Jan 29, 2026): [better-auth-capacitor](https://github.com/productdevbook/better-auth-capacitor) I published a library related to this.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27998