Expo Better Auth breaking with any client plugin "better-auth/client/plugins"

I narrowed down the issue to "better-auth/client/plugins", using any client plugin on expo breaks the app and figured out "jose" was the issue Here's a very basic repo with better auth which has the issue: https://github.com/abhay-ramesh/authTest ❗Someone help me out Thank You
import { expoClient } from "@better-auth/expo/client";
import { usernameClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import * as SecureStore from "expo-secure-store";

export const authClient = createAuthClient({
baseURL: "http://localhost:8081" /* base url of your Better Auth backend. */,
plugins: [
expoClient({
scheme: "myapp",
storagePrefix: "myapp",
storage: SecureStore,
}),
usernameClient(), // This causes the issue
],
});
import { expoClient } from "@better-auth/expo/client";
import { usernameClient } from "better-auth/client/plugins";
import { createAuthClient } from "better-auth/react";
import * as SecureStore from "expo-secure-store";

export const authClient = createAuthClient({
baseURL: "http://localhost:8081" /* base url of your Better Auth backend. */,
plugins: [
expoClient({
scheme: "myapp",
storagePrefix: "myapp",
storage: SecureStore,
}),
usernameClient(), // This causes the issue
],
});
GitHub
GitHub - abhay-ramesh/authTest
Contribute to abhay-ramesh/authTest development by creating an account on GitHub.
No description
14 Replies
Abhay Ramesh
Abhay RameshOP2w ago
Hey got it narrowed down to v1.1.19, any version before it works, havent tried the beta-versions
Shubham-Sinha
Shubham-Sinha2w ago
@admin 1.1.19 breaks in expo. issue with crypto module
No description
bekacru
bekacru2w ago
Hey guys, please try 1.1.20-beta.2 and report back
Abhay Ramesh
Abhay RameshOP2w ago
Got a different error with 1.1.20-beta.2
Cannot read property 'subtle' of undefined
Cannot read property 'subtle' of undefined
No description
bekacru
bekacru2w ago
is the auth import, the server auth instance?
Abhay Ramesh
Abhay RameshOP2w ago
Yes ig btw its this file
import { expo } from "@better-auth/expo";
import { db } from "@workspace/database"; // your drizzle instance
import { resend } from "@workspace/email";
import { keys } from "@workspace/email/keys";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { emailOTP, openAPI, username } from "better-auth/plugins";
import * as dotenv from "dotenv";

// Load environment variables
dotenv.config();

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg", // or "mysql", "sqlite"
}),
user: {
additionalFields: {
role: {
type: "string",
required: true,
defaultValue: "participant",
input: false, // don't allow user to set role
},
},
},
plugins: [
username(),
expo(),
openAPI(),
emailOTP({
async sendVerificationOTP(data, request) {
try {
const { email, otp } = data;

await resend.emails.send({
from: keys().RESEND_FROM,
to: email,
subject: "Your Verification Code",
html: `
<div>hi</div>
`,
});
} catch (error) {
console.error("Failed to send email:", error);
throw new Error("Failed to send verification email");
}
},
}),
],
trustedOrigins: ["myapp://", "http://localhost:3000"],
});
import { expo } from "@better-auth/expo";
import { db } from "@workspace/database"; // your drizzle instance
import { resend } from "@workspace/email";
import { keys } from "@workspace/email/keys";
import { betterAuth } from "better-auth";
import { drizzleAdapter } from "better-auth/adapters/drizzle";
import { emailOTP, openAPI, username } from "better-auth/plugins";
import * as dotenv from "dotenv";

// Load environment variables
dotenv.config();

export const auth = betterAuth({
database: drizzleAdapter(db, {
provider: "pg", // or "mysql", "sqlite"
}),
user: {
additionalFields: {
role: {
type: "string",
required: true,
defaultValue: "participant",
input: false, // don't allow user to set role
},
},
},
plugins: [
username(),
expo(),
openAPI(),
emailOTP({
async sendVerificationOTP(data, request) {
try {
const { email, otp } = data;

await resend.emails.send({
from: keys().RESEND_FROM,
to: email,
subject: "Your Verification Code",
html: `
<div>hi</div>
`,
});
} catch (error) {
console.error("Failed to send email:", error);
throw new Error("Failed to send verification email");
}
},
}),
],
trustedOrigins: ["myapp://", "http://localhost:3000"],
});
Abhay Ramesh
Abhay RameshOP2w ago
ok the prev screenshot is of a different repo, i created a repo just to test the bug you can use it to test it and even there had the same issue: https://github.com/abhay-ramesh/authTest its a very plain repo with expo and better-auth btw 1.1.20-beta.2 not working their either
GitHub
GitHub - abhay-ramesh/authTest
Contribute to abhay-ramesh/authTest development by creating an account on GitHub.
No description
Abhay Ramesh
Abhay RameshOP2w ago
ill try to test from v1.1.18 till v1.1.19 we might be able to narrow down to figure out which release caused it v1.1.18 works v1.1.19-beta.1 works v1.1.19-beta.2 doesn't work v1.1.19-beta.3 doesn't work v1.1.19 doesn't work
Abhay Ramesh
Abhay RameshOP2w ago
GitHub
feat(one-tap): improve Google One Tap integration with JWT verific...
…ion and improved prompt handling (#1452) * fix(auth): use options.baseURL instead of ctx.baseURL on trusted origins * feat(one-tap): improve Google One Tap integration with JWT verification a...
Abhay Ramesh
Abhay RameshOP2w ago
packages/better-auth/src/plugins/one-tap/index.ts Usage of "jose" might be the issue "Maybe" ok i manually removed oneTap from /node_modules/better-auth/dist/client/plugins.js and it worked
bekacru
bekacru2w ago
but jose is imported in the server instance. you sholdn't import the server in your react native code. if you need the type you should make sure to import it as a type
import type { auth } from "your-config"
import type { auth } from "your-config"
Abhay Ramesh
Abhay RameshOP2w ago
even if im not importing import { auth } from "my-config" have the issue
bekacru
bekacru2w ago
should be fixed on 1.1.20-beta.3
Abhay Ramesh
Abhay RameshOP2w ago
Hey thanks alot for the help, really love better-auth nice work

Did you find this page helpful?