Migrate from react-native-sdk to expo sdk

Hi is it possible to migrate existing users who are logged in on our app using the react native sdk (https://www.npmjs.com/package/@kinde-oss/react-native-sdk-0-7x) to the expo sdk? We want to keep the users logged in - can't seem to figure o ut how. to do this, any help would be appreciated! (We don't use Expo Go so lmk if that makes things easier) thank. you!
npm
@kinde-oss/react-native-sdk-0-7x
Kinde React Native SDK for authentication. Latest version: 2.0.2, last published: 5 months ago. Start using @kinde-oss/react-native-sdk-0-7x in your project by running npm i @kinde-oss/react-native-sdk-0-7x. There are no other projects in the npm registry using @kinde-oss/react-native-sdk-0-7x.
4 Replies
Abdiwak
Abdiwak3w ago
Hi Hackerman, Thanks for your question. I’ll run some tests to see if it’s possible to migrate users from the React Native SDK to the Expo SDK while keeping them logged in, and I’ll get back to you with my findings.
hackerman
hackermanOP3w ago
thanks, please let me know if you have an update here !
Abdiwak
Abdiwak3w ago
Hi Hackerman, Thanks for your question. The React Native SDK and Expo SDK use different token storage mechanisms and token handling approaches, so there’s no built-in way to directly migrate an active session between them. - The React Native SDK stores tokens using react-native-keychain. - The Expo SDK has its own token management system.
Because of this, tokens stored by one SDK aren’t automatically accessible to the other. If you want to attempt preserving logged-in sessions, you can try using the refresh token from the React Native SDK and passing it into the Expo SDK to obtain new access tokens. This will only work if: 1. Both SDKs are configured with the same Kinde application (same clientId and domain). 2. The refresh token is still valid (not expired or revoked). Extracting tokens from the React Native SDK:
import { Storage } from '@kinde-oss/react-native-sdk-0-7x';

const accessToken = await Storage.getAccessToken();
console.log('access_token', accessToken);

const refreshToken = await Storage.getRefreshToken();
console.log('refresh_token', refreshToken);
import { Storage } from '@kinde-oss/react-native-sdk-0-7x';

const accessToken = await Storage.getAccessToken();
console.log('access_token', accessToken);

const refreshToken = await Storage.getRefreshToken();
console.log('refresh_token', refreshToken);
Using token utilities in the Expo SDK (Expo 53+):
import { getUserProfile, getFlag, getRoles, refreshToken } from "@kinde/expo/utils";

// Example: get profile
const checkUserProfile = async () => {
const profile = await getUserProfile();
console.log("User profile:", profile);
};

// Example: use refresh token to get a new access token
const newTokens = await refreshToken({
domain: "https://mybusiness.kinde.com",
clientId: "client_id"
});
console.log("New tokens:", newTokens);
import { getUserProfile, getFlag, getRoles, refreshToken } from "@kinde/expo/utils";

// Example: get profile
const checkUserProfile = async () => {
const profile = await getUserProfile();
console.log("User profile:", profile);
};

// Example: use refresh token to get a new access token
const newTokens = await refreshToken({
domain: "https://mybusiness.kinde.com",
clientId: "client_id"
});
console.log("New tokens:", newTokens);
If the refresh token approach doesn’t work in your setup, the fallback is to have users log in again after migrating to the Expo SDK.

Please let me know how it goes.
hackerman
hackermanOP3d ago
Hi @Roshan Chapagain - Kinde I tried the above but it doesn't work because refreshToken() from @kinde/expo/utils doesn't take a refresh token that can be used to refresh the token. it uses the one that's internally set by the Expo SDK itself.

Did you find this page helpful?