Labsco
auth0 logo

auth0-ionic-vue

โ˜… 37

by auth0 ยท part of auth0/agent-skills

Use when adding Auth0 login, logout, or deep linking to an Ionic Vue app with Capacitor. Integrates @auth0/auth0-vue 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 Vue (Capacitor) Integration

Add Auth0 authentication to Ionic Vue applications using Capacitor. This skill covers native mobile authentication using the @auth0/auth0-vue SDK combined with @capacitor/browser and @capacitor/app plugins for deep link handling on iOS and Android.

When NOT to Use

Use CaseRecommended Skill
Vue SPA (no Capacitor/Ionic)auth0-vue
React SPA (no Capacitor/Ionic)auth0-react
React Native (bare CLI)auth0-react-native
Expo (React Native)auth0-expo
Ionic + React + Capacitorauth0-ionic-react
Ionic + Angular + Capacitorauth0-ionic-angular
Next.js (server-side)auth0-nextjs
Nuxt (server-side)auth0-nuxt
iOS native (Swift)auth0-swift
Android native (Kotlin)auth0-android

Detailed Documentation

  • Setup Guide โ€” Auth0 CLI automated setup (login, app creation, credential injection), Capacitor URL scheme registration, secret management
  • Integration Patterns โ€” Login/logout with Capacitor Browser, deep link callback handling, user profile, protected routes, token access, error handling
  • Testing & Reference โ€” Full API reference for createAuth0 options, useAuth0 composable, Capacitor plugin configuration, testing checklist, common issues

WebAuth Method

This SDK uses Auth0's Universal Login (WebAuth) via the Capacitor Browser plugin. The loginWithRedirect() method opens the Auth0 authorization endpoint in a system browser (SFSafariViewController on iOS, Chrome Custom Tabs on Android). After authentication, Auth0 redirects back to the app using a native callback URL with a custom scheme: {packageId}://{domain}/capacitor/{packageId}/callback. The @capacitor/app plugin captures this deep link, and handleRedirectCallback(url) processes the authorization code exchange.

Unlike standard native SDKs that use https://{domain}/android/{packageId}/callback or https://{domain}/ios/{bundleId}/callback, Ionic Capacitor apps use the Capacitor-specific callback path with the package ID as the URL scheme.

  • auth0-vue โ€” Vue SPA (browser-only, no Capacitor)
  • auth0-ionic-react โ€” Ionic with React and Capacitor
  • auth0-ionic-angular โ€” Ionic with Angular and Capacitor
  • auth0-react-native โ€” React Native (bare CLI, no Ionic/Capacitor)
  • auth0-expo โ€” Expo (React Native) with Auth0

Quick Reference

APIDescription
createAuth0(options)Vue plugin factory โ€” registers Auth0 with app.use()
useAuth0()Composable โ€” returns { isLoading, isAuthenticated, user, loginWithRedirect, logout, getAccessTokenSilently, handleRedirectCallback, error }
loginWithRedirect({ openUrl })Login via Universal Login โ€” use Browser.open() in openUrl callback
logout({ logoutParams, openUrl })Logout โ€” use Browser.open() in openUrl callback
handleRedirectCallback(url)Process Auth0 callback URL from deep link
getAccessTokenSilently()Get access token (uses refresh tokens on mobile)
createAuthGuard(app)Vue Router navigation guard factory for protected routes
Browser.open({ url })Capacitor โ€” opens URL in system browser (SFSafariViewController / Chrome Custom Tabs)
CapApp.addListener('appUrlOpen', cb)Capacitor โ€” listens for deep link events
Browser.close()Capacitor โ€” closes the in-app browser after callback

References