Skip to content

Vue adapter

Install

Terminal window
pnpm add @vendidit/auth-client vue

Install the plugin

import { createApp } from 'vue';
import { VendiditAuthPlugin } from '@vendidit/auth-client/vue';
import App from './App.vue';
createApp(App)
.use(VendiditAuthPlugin, {
apiBaseUrl: 'https://auth.vendidit.com/api/v1',
appCode: 'marketplace-buyer',
})
.mount('#app');

Read auth state

<script setup lang="ts">
import { useAuth } from '@vendidit/auth-client/vue';
const { user, isAuthenticated, logout } = useAuth();
</script>
<template>
<div v-if="isAuthenticated">
{{ user.email }}
<button @click="logout()">Sign out</button>
</div>
<a v-else href="/login">Sign in</a>
</template>

The Vue composable returns ref/computed so the template is auto-reactive.