Firebase Authentication

Use the Firebase client functions to authenticate users.

Quick Start:

Usage Example (in a client component):

---
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>
    

Available Methods:

  • Create a `.env.local` file with your Firebase credentials
  • Use the functions above to handle authentication
  • Import these functions in interactive components with `client:` directives
  • Usage Example:

    import { handleLogin } from '@/pages/auth-example';
    
    async function login() {
      const user = await handleLogin('user@example.com', 'password123');
    }