Skip to content

Integrating with VueJS

Terminal window
npm install @authaction/web-sdk
main.ts
import { createApp } from "vue";
import { createAuthAction } from "@authaction/web-sdk/vue";
const app = createApp(App);
app.use(
createAuthAction({
domain: "myapp.eu.authaction.com",
clientId: "your-client-id",
redirectUri: "http://localhost:5173/callback",
})
);
app.mount("#app");
<script setup>
import { useAuthAction } from "@authaction/web-sdk/vue";
const { state, loginWithRedirect, logout } = useAuthAction();
</script>
<template>
<button v-if="!state.isAuthenticated" @click="loginWithRedirect()">Login</button>
<button v-else @click="logout()">Hello {{ state.user?.name }}</button>
</template>

Full SDK reference: github.com/authaction/authaction-web-sdk