Hi everyone ,
I’ve been testing the official Auth0 React quickstart for Ionic + Capacitor. After two days of testing, here’s what I found:
-
Web: Demo app works fine with minor setup adjustments. isAuthenticated
and user
update as expected.
-
Mobile HTTPS/WebView: Works in mobile browser or WebView—but this is just the web app running on mobile, not a true native app.
-
Native build: Auth0 completely fails:
-
user
is undefined
(I tried to display user.name
and user.email
, but nothing shows up.
-
isAuthenticated
is always false
-
Logout/login works, but useAuth0
hook never provides values
Question:
Has anyone successfully used the Auth0 React quickstart with Ionic & Capacitor in a native app? How do you ensure isAuthenticated
and user
Update correctly on native builds?
Any guidance or examples would be greatly appreciated!
Welcome back to the Auth0 Community!
I will be taking a look at the issue that you are having and will come back with an update on both of your posts as soon as possible. Thank you for your patience!
Kind Regards,
Nik
Hi again @extrat30
Could you creating a hook in order to update the the token in the background at specific intervals as stated in this StackOverflow thread?
Also, by any chance do you have your App component wrapped in inside the index.tsx
or other index files?
Kind Regards,
Nik
Here is my observation after trying for the past two days:
-
Your demo app for Ionic + Capacitor (React) works fine on the web. I did encounter some minor errors that needed setup, but overall it works.
-
If I serve the app with HTTPS on my mobile, it runs fine in the mobile browser or in a WebView. However, this is just a projection of the web app running on mobile—it’s not the real native app.
-
When I build the app for a native environment, Auth0 completely fails. I don’t get any user data, and isAuthenticated
is always false. I can log out and log in perfectly, but the useAuth0
hook does not provide any of these values.
Initially, I thought the issue was that useEffect
was not triggering, but after testing, it turns out the main issue is that in the native app, I simply don’t get the Auth0 values at all. I’m not sure why it’s failing or what the correct approach should be for Auth0 in a fully native environment.
I think you can check that out too. Just run your example app and build that native app you will find that issue too