Use the Firebase client functions to authenticate users.
---
import { signInWithEmailAndPassword } from 'firebase/auth';
import { auth } from '@/firebase.client';
---
<button onclick={handleLogin}>Login</button>
<script>
export async function handleLogin() {
const email = 'user@example.com';
const password = 'password123';
const result = await signInWithEmailAndPassword(auth, email, password);
console.log('User logged in:', result.user);
}
</script>
signInWithEmailAndPassword(auth, email, password) - Sign in existing usercreateUserWithEmailAndPassword(auth, email, password) - Create new usersignOut(auth) - Sign out current usersignInWithPopup(auth, provider) - Sign in with Google/GitHub/etconAuthStateChanged(auth, callback) - Listen to auth changesimport { handleLogin } from '@/pages/auth-example';
async function login() {
const user = await handleLogin('user@example.com', 'password123');
}