BA
Better Auth•17h ago
ak11

Offline support for expo apps

so i'm building an expo app that is to be built on iOS, android as well as to be deployed on the web. i moved away from clerk seeing they've not made enough progress in heir offline support. i need guidance on what to do. i'm tring to build a local first business management tool and one of my requirements is that iw ould want to be able to open my application without necessarily having an internet connection. i thought with the sessions being stored on the user device using expo-securestore i thought that would be a possibility, but it's not. please your help would be very much appreciated
3 Replies
ak11
ak11OP•10h ago
this is my current protecteRoute set's up that wraps the entry of my app
import React, { useEffect } from 'react';
import { router, useSegments } from 'expo-router';
import { authClient } from '@/authClient';

interface ProtectedRouteProps {
children: React.ReactNode;
}

export const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => {
const { data: session, isPending: isSessionPending } =
authClient.useSession();
const { data: activeOrg, isPending: isOrgPending } =
authClient.useActiveOrganization();

const segments = useSegments();

useEffect(() => {
if (!session && !isSessionPending) {
router.push('/sign-in');
}
if (
!session &&
!isSessionPending &&
!activeOrg &&
!isOrgPending &&
segments[0] !== '(org-list)'
) {
router.push('/recent-businesses');
}
}, [session, isSessionPending, activeOrg, isOrgPending]);

if (!session) return null;

return children;
};
import React, { useEffect } from 'react';
import { router, useSegments } from 'expo-router';
import { authClient } from '@/authClient';

interface ProtectedRouteProps {
children: React.ReactNode;
}

export const ProtectedRoute: React.FC<ProtectedRouteProps> = ({ children }) => {
const { data: session, isPending: isSessionPending } =
authClient.useSession();
const { data: activeOrg, isPending: isOrgPending } =
authClient.useActiveOrganization();

const segments = useSegments();

useEffect(() => {
if (!session && !isSessionPending) {
router.push('/sign-in');
}
if (
!session &&
!isSessionPending &&
!activeOrg &&
!isOrgPending &&
segments[0] !== '(org-list)'
) {
router.push('/recent-businesses');
}
}, [session, isSessionPending, activeOrg, isOrgPending]);

if (!session) return null;

return children;
};
Could you help please? @Ping
Ping
Ping•10h ago
Sorry I don't have much experience in Expo. 😅 Maybe @bekacru could help?
ak11
ak11OP•5h ago
okay hhey @bekacru

Did you find this page helpful?