After upgrading from 1.2.12 to 1.3.28, expo doesn't persists session in SecureStorage anymore.

So, i updated my dependencies (@better-auth/expo, better-auth) to 1.3.28 and now it doesn't persist the session anymore. I have a very simple authClient, see:
import { expoClient } from "@better-auth/expo/client";
import { createAuthClient } from "better-auth/react";
import Constants from "expo-constants";
import * as SecureStore from "expo-secure-store";

const BASE_URL = process.env.EXPO_PUBLIC_AUTH_URL || "http://localhost:8081";

const scheme = Constants.expoConfig?.scheme as string;

export const authClient = createAuthClient({
baseURL: BASE_URL,
plugins: [
expoClient({
scheme: scheme,
storagePrefix: scheme,
storage: SecureStore,
}),
],
});
import { expoClient } from "@better-auth/expo/client";
import { createAuthClient } from "better-auth/react";
import Constants from "expo-constants";
import * as SecureStore from "expo-secure-store";

const BASE_URL = process.env.EXPO_PUBLIC_AUTH_URL || "http://localhost:8081";

const scheme = Constants.expoConfig?.scheme as string;

export const authClient = createAuthClient({
baseURL: BASE_URL,
plugins: [
expoClient({
scheme: scheme,
storagePrefix: scheme,
storage: SecureStore,
}),
],
});
Im using a nextJs Application as auth Backend. This is really weird because when i downgrade it works just fine. Anyone has a clue?
1 Reply
ikoepp
ikoeppOPthis hour
I found out that using a cookieprefix breaks the mobile client because secure storage doesnt allow saving tokens using colons in name. Issue: https://github.com/better-auth/better-auth/issues/5426
GitHub
[Expo] SecureStore fails with "Invalid key" error - storage keys us...
Is this suited for github? Yes, this is suited for github To Reproduce The @better-auth/expo plugin generates storage keys with colon separators (e.g., prefix:cookie), but expo-secure-store only ac...

Did you find this page helpful?