supabase icon indicating copy to clipboard operation
supabase copied to clipboard

How to use this with pinia?

Open jlemonz opened this issue 1 year ago • 1 comments

Hi,

How can i use this with pinia? I tried this code. But this gives errors that it cannot fetch when i try to login.

`// stores/auth.js

import { defineStore } from 'pinia'; import { ref, computed } from 'vue'; import { useSupabaseClient } from '#imports';

export const useAuthStore = defineStore('auth', () => { const supabase = useSupabaseClient(); const user = ref(null); const error = ref(null);

const isAuthenticated = computed(() => !!user.value);

const signIn = async (email, password) => { try { const { data, error: signInError } = await supabase.auth.signInWithPassword({ email, password, }); if (signInError) throw signInError; user.value = data.user; } catch (err) { error.value = err.message; } };

return { user, error, isAuthenticated, signIn }; }); `

jlemonz avatar Oct 01 '24 20:10 jlemonz

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 30 days.

github-actions[bot] avatar May 06 '25 13:05 github-actions[bot]