- set the client
const supabase = useSupabaseClient();
- create a function (this one does not need to be async) for logout
function logout() {
try {
const { error } = supabase.auth.signOut();
if (error) {
throw error;
}
} catch (error) {
console.error(error)
}
}
- attach the function to the logout button
<button @click="logout">Log out</button>
- In the devtools, check Application Tab -> Local Storage ->
sb-
access token
- get the user info from the session and print it to the page (it will disappear on a successful log out)
<script setup>
const user = useSupabaseUser();
</script>
<template>
<p>{{ user }}</p>
</template>