Expo: TypeError: Cannot read property 'subtle' of undefined

I updated the Expo client library and want to implement the magic link plugin, but when I try to use this plugin I'm receiving:
TypeError: Cannot read property 'subtle' of undefined
TypeError: Cannot read property 'subtle' of undefined
How could I fix it?
8 Replies
edwardrenton
edwardrenton5w ago
Did you solve this? Now having it on 1.3.7
HoshangDEV
HoshangDEV4w ago
Same here :/ 1.3.9
thesiddd
thesiddd4w ago
same here as well!
Aswin
Aswin4w ago
same here.
HoshangDEV
HoshangDEV4w ago
instead of using the Client plugins, I removed the plugins from the client side, and used $fetch method with the needed URL, for example: before:
const { data, error } = await authClient.twoFactor.sendOtp();
const { data, error } = await authClient.twoFactor.sendOtp();
after:
const { data: otp, error } = await authClient.$fetch(
"/two-factor/send-otp"
);
const { data: otp, error } = await authClient.$fetch(
"/two-factor/send-otp"
);
OR before:
const { data, error } = await authClient.twoFactor.verifyOtp({
code: code,
trustDevice: true,
});
const { data, error } = await authClient.twoFactor.verifyOtp({
code: code,
trustDevice: true,
});
after:
const { data, error } = await authClient.$fetch(
"/two-factor/verify-otp",
{
body: {
code: values.otp,
trustDevice: values.trustDevice,
},
}
);
const { data, error } = await authClient.$fetch(
"/two-factor/verify-otp",
{
body: {
code: values.otp,
trustDevice: values.trustDevice,
},
}
);
my current
auth-client.ts
auth-client.ts
import { expoClient } from "@better-auth/expo/client";
import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient({
baseURL: process.env.EXPO_PUBLIC_API_URL,
fetchOptions: {
credentials: "include",
method: "POST",
},
plugins: [
expoClient({
scheme: "paxmanagementapp",
storagePrefix: "paxmanagementapp",
storage: SecureStore,
}),
],
});
import { expoClient } from "@better-auth/expo/client";
import { createAuthClient } from "better-auth/react";

export const authClient = createAuthClient({
baseURL: process.env.EXPO_PUBLIC_API_URL,
fetchOptions: {
credentials: "include",
method: "POST",
},
plugins: [
expoClient({
scheme: "paxmanagementapp",
storagePrefix: "paxmanagementapp",
storage: SecureStore,
}),
],
});
The only down side for me is type safety, if we use the plugins the types are already handled, but since the $fetch does not know what is the response we have to handle the types manually.
Aswin
Aswin4w ago
Yeah i actually just removed the plugin from auth-client.ts and everything still worked, without updating the actual usage of the plugin functions. It shows type errors but it works still lol. Library definitely needs to address this issue.
Alex Yang
Alex Yang4w ago
hi, have you try to bump to the latest version? 1.3.9 can you try this? https://github.com/better-auth/better-auth/issues/4471#issuecomment-3284336659 I think subtle is still not working. let me thing how to do that
HoshangDEV
HoshangDEV4w ago
GitHub
React Native build issue on v1.3.8 · Issue #4471 · better-auth/be...
Is this suited for github? Yes, this is suited for github To Reproduce Create a new expo app, install better-auth@1.3.8 and @better-auth/expo@1.3.8, setup according to docs, import a plugin from be...

Did you find this page helpful?