celestialcity
celestialcity
BABetter Auth
Created by celestialcity on 3/27/2025 in #help
Expo - In-app browser not showing up
Hi, I'm using better-auth hosted on a next.js backend With Expo, I'm following the documentation and the login button (physical and simulator) is not doing anything (no redirect, browser, etc.)
import { authClient } from "@/lib/auth-client";
import { Button, View, Text } from "react-native";

export default function Page() {
const loginWithGoogle = async () => {
await authClient.signIn.social({
provider: "google",
disableRedirect: true,
callbackURL: "(tabs)",
});
};

return (
<View style={{ paddingVertical: 50, paddingHorizontal: 20 }}>
<Button title="Login" onPress={loginWithGoogle} />
</View>
);
}
import { authClient } from "@/lib/auth-client";
import { Button, View, Text } from "react-native";

export default function Page() {
const loginWithGoogle = async () => {
await authClient.signIn.social({
provider: "google",
disableRedirect: true,
callbackURL: "(tabs)",
});
};

return (
<View style={{ paddingVertical: 50, paddingHorizontal: 20 }}>
<Button title="Login" onPress={loginWithGoogle} />
</View>
);
}
import { createAuthClient } from "better-auth/react";
import { expoClient } from "@better-auth/expo/client";
import * as SecureStore from "expo-secure-store";

export const authClient = createAuthClient({
baseURL:
process.env.EXPO_PUBLIC_APP_URL /* base url of your Better Auth backend. */,
plugins: [
expoClient({
scheme: "invis",
storagePrefix: "invis",
storage: SecureStore,
}),
],
});
import { createAuthClient } from "better-auth/react";
import { expoClient } from "@better-auth/expo/client";
import * as SecureStore from "expo-secure-store";

export const authClient = createAuthClient({
baseURL:
process.env.EXPO_PUBLIC_APP_URL /* base url of your Better Auth backend. */,
plugins: [
expoClient({
scheme: "invis",
storagePrefix: "invis",
storage: SecureStore,
}),
],
});
Config:
import { betterAuth, type BetterAuthOptions } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { expo } from "@better-auth/expo";
import { prisma } from "@invisible/db";
import { nextCookies } from "better-auth/next-js";

export const config: BetterAuthOptions = {
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60,
},
},
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
trustedOrigins: ["invis://"],
plugins: [nextCookies(), expo()],
};

export const auth = betterAuth(config);
import { betterAuth, type BetterAuthOptions } from "better-auth";
import { prismaAdapter } from "better-auth/adapters/prisma";
import { expo } from "@better-auth/expo";
import { prisma } from "@invisible/db";
import { nextCookies } from "better-auth/next-js";

export const config: BetterAuthOptions = {
session: {
cookieCache: {
enabled: true,
maxAge: 5 * 60,
},
},
database: prismaAdapter(prisma, {
provider: "postgresql",
}),
socialProviders: {
google: {
clientId: process.env.GOOGLE_CLIENT_ID as string,
clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,
},
},
trustedOrigins: ["invis://"],
plugins: [nextCookies(), expo()],
};

export const auth = betterAuth(config);
4 replies