React Native Session Provider

Is there an example anywhere showing how to create a session provider with the Kinde React Native SDK in an expo app? Here is the Expo docs on how they encourage to use React Context and Route Groups https://docs.expo.dev/router/reference/authentication/ Would it make sense to use the Kinde React SDK?
Expo Documentation
Authentication in Expo Router
How to implement authentication and protect routes with Expo Router.
2 Replies
onderay
onderay5mo ago
Sorry we dont yet, but will ask a team member to check over the URL your provided and see how we could improve our support. Authentication Flow You can implement a basic authentication flow using the SDK's methods. Here's a general approach:
const checkAuthenticate = async () => {
if (await client.isAuthenticated) {
// User is authenticated, handle accordingly
} else {
// User is not authenticated, handle accordingly
}
};

useEffect(() => {
checkAuthenticate();
}, []);

const handleSignIn = async () => {
const token = await client.login();
if (token) {
// Handle successful sign-in
}
};

const handleSignUp = async () => {
const token = await client.register();
if (token) {
// Handle successful sign-up
}
};

const handleLogout = async () => {
const isLoggedOut = await client.logout();
if (isLoggedOut) {
// Handle successful logout
}
};
const checkAuthenticate = async () => {
if (await client.isAuthenticated) {
// User is authenticated, handle accordingly
} else {
// User is not authenticated, handle accordingly
}
};

useEffect(() => {
checkAuthenticate();
}, []);

const handleSignIn = async () => {
const token = await client.login();
if (token) {
// Handle successful sign-in
}
};

const handleSignUp = async () => {
const token = await client.register();
if (token) {
// Handle successful sign-up
}
};

const handleLogout = async () => {
const isLoggedOut = await client.logout();
if (isLoggedOut) {
// Handle successful logout
}
};
Token Storage The SDK securely stores tokens using expo-secure-store. You can access these tokens like this:
import { Storage } from '@kinde-oss/react-native-sdk-0-7x'

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

const accessToken = await Storage.getAccessToken();
console.log('access_token', accessToken);
jonericcook
jonericcookOP5mo ago
Thank you
Want results from more Discord servers?
Add your server