Hi everyone,
I’m testing the official Auth0 React quickstart with Ionic & Capacitor. I didn’t make any changes—just downloaded the code and ran it on both web and Android.
-
Web: Everything works perfectly.
isAuthenticated
anduser
Update as expected after login. -
Mobile (Android/iOS): After logging in,
isAuthenticated
remainsfalse
anduser
doesn’t update at all.
Here’s the relevant code (official GitHub quickstart, I only added a logout button for testing):
// @ts-nocheck
import {
IonContent,
IonHeader,
IonPage,
IonTitle,
IonToolbar,
} from "@ionic/react";
import { useAuth0 } from "@auth0/auth0-react";
import "./Home.css";
import LoginButton from "../components/LoginButton";
import LogoutButton from "../components/LogoutButton";
import Profile from "../components/Profile";
const Home: React.FC = () => {
const { isLoading, isAuthenticated, user } = useAuth0();
console.log(isLoading, user);
if (isLoading) {
return <div>Loading..... </div>;
}
return (
<IonPage>
<IonHeader>
<IonToolbar>
<IonTitle>Auth0 React Sample</IonTitle>
</IonToolbar>
</IonHeader>
<IonContent fullscreen>
<IonHeader collapse="condense">
<IonToolbar>
<IonTitle size="large">Auth0 React Sample</IonTitle>
</IonToolbar>
</IonHeader>
<div className="container">
<span>{"is authenticated:" + isAuthenticated}</span>
<Profile />
<>
<LogoutButton />
<LoginButton />
</>
</div>
</IonContent>
</IonPage>
);
};
export default Home;
I suspect this might be related to the difference in how Auth0 handles web vs native mobile login flows.
Has anyone successfully used the Auth0 React quickstart with Ionic & Capacitor on mobile? How do you ensure isAuthenticated
and user
Update correctly on native apps?
Any guidance would be greatly appreciated!