DEV Community

Cover image for Expo Router V2 - Authentication Flow with Appwrite

Expo Router V2 - Authentication Flow with Appwrite

Aaron K Saunders on July 10, 2023

This blog post is a complimentary resource to support the video on Expo Router v2 In the video, I walk you through the code for an authentication ...
Collapse
 
davidhenry profile image
David Henry

I think I'm missing something as when I have a user it falls through to a [...missing] page.

Here I think is my issue as there is a missing edge case in:

if (
// If the user is not signed in and the initial segment is not anything in the auth group.
!user &&
!inAuthGroup
) {
// Redirect to the sign-in page.
router.push("/sign-in");
} else if (user && inAuthGroup) {
// Redirect away from the sign-in page.
router.push("/");
}

Potentially missing... if (user && !inAuthGroup) { ...

Everything else works perfectly. Just trying to figure out where I went wrong.

Collapse
 
aaronksaunders profile image
Aaron K Saunders

do you have a simple project somewhere i could take a look at?

Collapse
 
davidhenry profile image
David Henry

Yes, sure - where do I share it?

Thread Thread
 
aaronksaunders profile image
Aaron K Saunders

You can DM me on Twitter if you don’t want to post link to project here

Thread Thread
 
davidhenry profile image
David Henry

Wouldn't let me DM so dropped you an email hope you don't mind. Have a great day man!

Thread Thread
 
aaronksaunders profile image
Aaron K Saunders

i dont see an email?

Thread Thread
 
davidhenry profile image
David Henry • Edited

HYG, github.com/davidlintin/expo-router... here are all the Authentication files let me know if you need more.

Thread Thread
 
aaronksaunders profile image
Aaron K Saunders

this is not a project :-(

Thread Thread
 
davidhenry profile image
David Henry • Edited

Ah sorry, finally figured out GitHub :) [(github.com/davidlintin/expo-router...]

Collapse
 
vins13pattar profile image
Vinod S Pattar

Saved my day!!! Post upgrading to SDK 49 and router v2 I was struggling with authentication issues!! Thank you for the wonderful solution.

Collapse
 
olalexy1 profile image
Olalekan Ajayi • Edited

Thank you for this tutotial. I tried this solution and replaced it with firebase-auth but I am getting an unmatched route on app load, Been on this for some days, Pls can you help take a look?

Collapse
 
aaronksaunders profile image
Aaron K Saunders

do you have a sample project i can take a look at?