Labsco
auth0 logo

auth0-ionic-angular

โ˜… 37

by auth0 ยท part of auth0/agent-skills

Use when adding Auth0 login, logout, or deep linking to an Ionic Angular app with Capacitor. Integrates @auth0/auth0-angular with Capacitor Browser and App plugins for native iOS/Android.

๐Ÿงฉ One of 7 skills in the auth0/agent-skills package โ€” works on its own, and pairs well with its siblings.

This is the playbook your agent receives when the skill activates โ€” you don't need to read it to use the skill, but it's here to audit before installing.

Auth0 Ionic Angular (Capacitor) Integration

Add authentication to an Ionic Angular application using the @auth0/auth0-angular SDK with Capacitor plugins for native iOS and Android. This skill covers login, logout, user profile display, and secure token management using the system browser (SFSafariViewController on iOS, Chrome Custom Tabs on Android) via Capacitor's Browser plugin.

When NOT to Use

Use CaseRecommended Skill
Ionic React app with Capacitorauth0-ionic-react
Ionic Vue app with Capacitorauth0-ionic-vue
Angular SPA (browser-only, no Capacitor)auth0-angular or auth0-react
React Native (no Ionic)auth0-react-native
Expo (React Native)auth0-expo
Native iOS (Swift)auth0-swift
Native Android (Kotlin)auth0-android

Detailed Documentation

  • Setup Guide โ€” Auth0 configuration, Auth0 CLI setup, Capacitor platform setup, deep linking
  • Integration Patterns โ€” Login/logout flows, token management, user profile, error handling, Capacitor lifecycle
  • API Reference & Testing โ€” AuthService API, configuration options, claims reference, testing checklist

WebAuth Method

Ionic with Capacitor uses the Web Auth method for authentication:

  1. User taps Log In โ†’ app calls loginWithRedirect with a custom openUrl that uses Browser.open()
  2. Capacitor's Browser plugin opens the Auth0 Universal Login page in the system browser (SFSafariViewController / Chrome Custom Tabs)
  3. User authenticates โ†’ Auth0 redirects to the custom URL scheme callback
  4. OS routes the deep link to your app โ†’ appUrlOpen event fires
  5. handleRedirectCallback(url) processes the auth code exchange inside ngZone.run()
  6. Browser.close() dismisses the system browser
  7. auth.isAuthenticated$ emits true, and auth.user$ emits the user profile
  • auth0-ionic-react โ€” Ionic React with Capacitor
  • auth0-ionic-vue โ€” Ionic Vue with Capacitor
  • auth0-angular โ€” Angular SPA (browser-only)
  • auth0-swift โ€” Native iOS (Swift)
  • auth0-android โ€” Native Android (Kotlin)

Quick Reference

APIDescription
AuthService.loginWithRedirect(options)Start login flow with custom openUrl for Capacitor
AuthService.logout(options)Log out with custom openUrl and returnTo
AuthService.handleRedirectCallback(url)Process the callback URL from the deep link
AuthService.isAuthenticated$Observable boolean โ€” whether user is logged in
AuthService.user$Observable โ€” current user profile (name, email, picture)
AuthService.isLoading$Observable boolean โ€” SDK initialization state
AuthService.error$Observable โ€” authentication errors
AuthService.getAccessTokenSilently()Get access token (uses refresh tokens on mobile)
Browser.open({ url })Open URL in system browser (Capacitor)
CapApp.addListener('appUrlOpen', cb)Listen for deep link callbacks (Capacitor)

References