When asking for help in this category, please make sure to provide the following details:
- SDK Version: 8.1.0
- Platform: Android/iOS
- Browser Console Screenshots:
- If the issue is related to Custom Authentication, please include the following information (optional):
- Verifier Name:
- JWKS Endpoint:
- Sample idToken (JWT):
Also, kindly provide the Web3Auth initialization and login code snippet below. This will help us better understand your issue and provide you with the necessary assistance.
I’m integrating the Web3Auth React-Native PnP SDK into an Expo-based mobile app (Custom Dev Client). Regardless of reload type or app lifecycle, the session is never re-hydrated:
- Fast Refresh / JS reload: Immediately after pressing “r” in Metro, I must log in again.
- App switch (background ↔ foreground): After switching away and returning, session is lost.
- Full process kill (app removed from recents): Naturally also prompts for re-login.
I have set sessionTime
to the maximum (86400 seconds).
Initialization & Session-Restore Code
// mobileWalletConfig.ts
export const web3auth = new Web3Auth(WebBrowser, SecureStore, {
clientId: "<MY_CLIENT_ID>",
network: WEB3AUTH_NETWORK.CYAN,
privateKeyProvider: new EthereumPrivateKeyProvider({ config: { chainConfig } }),
redirectUrl: "com.myapp.mobile://auth",
enableLogging: true,
sessionTime: 86400, // 1 day
});
export const initWeb3Auth = async () => {
await web3auth.init();
return web3auth;
};
// Initialize Web3Auth and check for existing session
useEffect(() => {
const initWeb3Auth = async () => {
try {
await initWeb3AuthMobile();
setWeb3auth(web3authInstance);
console.log("web3authInstance", web3authInstance);
// Check if user is already logged in
if (web3authInstance.connected) {
setIsConnecting(true);
try {
const privateKey = await web3authInstance.provider?.request({
method: "eth_private_key",
});
if (typeof privateKey === "string") {
const cleanPrivateKey = privateKey.startsWith("0x") ? privateKey.slice(2) : privateKey;
const formattedPrivateKey = `0x${cleanPrivateKey}` as Hex;
const account = privateKeyToAccount(formattedPrivateKey);
setCurrentWallet(account.address);
setIsSocial(true);
}
} catch (error) {
console.error("Error restoring session:", error);
// If there's an error restoring the session, log out
await web3authInstance.logout();
} finally {
setIsConnecting(false);
}
}
} catch (error) {
console.error("Error initializing Web3Auth:", error);
}
};
initWeb3Auth();
}, []);
Login & Connector Code
// Trigger on user tap
await web3auth.login({
loginProvider: LOGIN_PROVIDER.GOOGLE,
redirectUrl: "com.myapp.mobile://auth",
mfaLevel: "default",
});
// web3authRnConnector.ts
export function Web3AuthConnector({ web3AuthInstance, loginParams }) {
return createConnector((config) => ({
id: "web3Auth",
name: "Web3Auth",
type: "web3Auth",
async connect() {
if (!web3AuthInstance.connected) {
await web3AuthInstance.login(loginParams);
}
const rawKey = await web3AuthInstance.provider!.request({ method: "eth_private_key" });
const account = privateKeyToAccount(rawKey.startsWith("0x") ? rawKey : `0x${rawKey}`);
const chainHex = await web3AuthInstance.provider!.request({ method: "eth_chainId" });
return { accounts: [account.address], chainId: Number(chainHex) };
},
async isAuthorized() {
return web3AuthInstance.connected;
},
async disconnect() {
await web3AuthInstance.logout();
},
// …getAccounts, getChainId, event handlers…
}));
}
Questions
- Should Fast Refresh or background→foreground transitions trigger a re-login? My understanding is that SecureStore data survives JS reloads—am I missing a step?
- Are there any additional native or Expo configuration steps required to ensure session data is re-hydrated?
- How can I verify that SecureStore is indeed persisting the Web3Auth session? Is there a recommended pattern to inspect or dump stored keys for debugging?
- Has anyone seen this behavior in a Custom Dev Client / standalone build and successfully kept the session alive until TTL expiry?
Any pointers, sample repos, or configuration tips would be greatly appreciated—thanks in advance!