#what must be my SITE_URL for an android app. i use expo

4 messages · Page 1 of 1 (latest)

obtuse rune
#

what must be my SITE_URL for an android app. i use expo

iron dewBOT
#

Hi @obtuse rune. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:

#

For an Android app using Expo, your SITE_URL should be set to your app's custom URI scheme, such as myapp://. This is necessary because, on mobile, OAuth and magic link redirects need to return to your app using a deep link rather than a web URL.

From the Convex Discord support threads, the recommended approach is:

  • Set SITE_URL to your app's deep link, e.g., myapp://, for mobile.
  • If you are supporting both web and mobile, you cannot have both working at the same time with a single SITE_URL value. In this case, you should set SITE_URL to a placeholder value and implement a custom redirect callback in your Convex Auth config to allow both your web and mobile redirect URIs. The callback should validate and return the appropriate redirectTo value based on the platform.

Example custom callback (from Discord):

export const { auth, signIn, signOut, store, isAuthenticated } = convexAuth({
  providers: [Google],
  callbacks: {
    async redirect({ redirectTo }) {
      if (
        redirectTo !== "myapp://" &&
        redirectTo !== "<http://localhost:8081">
      ) {
        throw new Error(`Invalid redirectTo URI ${redirectTo}`);
      }
      return redirectTo;
    },
  },
});

And in your frontend, pass the correct absolute redirectTo URL depending on the platform.