Skip to content

Overview

The WSO2 Identity Server Vue SDK (@asgardeo/vue) adds authentication to Vue 3 single-page applications. It gives you a Vue plugin, a root provider component, ready-made components for sign-in, sign-out, user profiles and organizations, and composables that expose the authentication state and methods to your own components.

The SDK is built on the WSO2 Identity Server Browser SDK. It uses the OpenID Connect authorization code flow with PKCE and keeps the session in the browser.

Installation

Use one of the following options to install the WSO2 Identity Server Vue SDK.

npm install @asgardeo/vue
yarn add @asgardeo/vue
pnpm add @asgardeo/vue

Getting started

Try out the WSO2 Identity Server Vue quickstart guide.

A minimal setup installs the plugin and wraps your app with <AsgardeoProvider>:

src/main.js
import { createApp } from 'vue'
import { AsgardeoPlugin } from '@asgardeo/vue'
import App from './App.vue'

createApp(App).use(AsgardeoPlugin).mount('#app')
src/App.vue
<script setup>
import { SignedIn, SignedOut, SignInButton, SignOutButton, UserDropdown } from '@asgardeo/vue'
</script>

<template>
  <AsgardeoProvider
    client-id="<your-app-client-id>"
    base-url="https://localhost:9443"
  >
    <SignedIn>
      <UserDropdown />
      <SignOutButton />
    </SignedIn>
    <SignedOut>
      <SignInButton />
    </SignedOut>
  </AsgardeoProvider>
</template>

Plugin and provider

  • AsgardeoPlugin – The Vue plugin. Install it with app.use() to register <AsgardeoProvider> globally and add the SDK's styles.
  • <AsgardeoProvider> – The root component that configures the SDK and shares the authentication state with every component inside it.

Components

Import components from @asgardeo/vue in the components that use them. Only <AsgardeoProvider> is registered globally by the plugin.

Action components

Control components

  • <SignedIn> – Renders its content only when the user is signed in.
  • <SignedOut> – Renders its content only when the user is signed out.
  • <Loading> – Renders its content while the SDK is busy.

Authentication components

  • <SignIn> – An embedded sign-in form rendered inside your app.
  • <SignUp> – An embedded self-registration form rendered inside your app.

User self-care components

  • <User> – Exposes the signed-in user through a scoped slot.
  • <UserProfile> – Displays the user's profile and lets them edit it.
  • <UserDropdown> – An avatar button that opens a menu with the user's details, a profile view and sign-out.

Organization components (B2B)

Internationalization components

Composables

Call composables from components rendered inside <AsgardeoProvider>.

  • useAsgardeo() – Authentication state and methods for sign-in, sign-out, tokens and HTTP requests.
  • useUser() – The signed-in user's profile and the schemas that describe it.
  • useOrganization() – The current organization, the user's organizations and organization switching.
  • useI18n() – The current language, language switching and translations.
  • useTheme() – The theme applied to the SDK's components and light or dark mode switching.

Guides