@kolaylogin/vue
Vue 3 composables — provide once near the root, then call useAuth() / useUser() / useSession() in any component. Auto-refresh runs while the provider is mounted.
Copy this quickstart guide as a prompt for LLMs to implement KolayLogin in your application.
Install
npm install @kolaylogin/vueProvide + use
src/App.vue (setup)
<script setup lang="ts">
import { provideKolayLogin, useAuth, useUser } from '@kolaylogin/vue';
provideKolayLogin({ baseUrl: "https://api.kolaylogin.com" });
const auth = useAuth(); // ComputedRef<AuthObject>
const { user, isLoaded } = useUser();
</script>
<template>
<template v-if="auth.isSignedIn">
<p>Hi {{ user?.email }}</p>
</template>
<template v-else>
<a href="/sign-in">Sign in</a>
</template>
</template>Exports
provideKolayLogin({ baseUrl, autoRefresh, refreshSkewSeconds })— call once.useAuth()—ComputedRefwithisSignedIn,userId,orgId,getToken().useSession()— raw sessionRef(signed_in/signed_out).useUser()— lazy fetch of the current user record.useKolayLogin()— escape hatch withbaseUrl+refresh().
Building a form? POST credentials to {baseUrl}/v1/auth/sign-in/email-password with credentials: 'include'. The next useUser() tick picks up the newly-set cookie automatically.