'use client'; import { signIn } from '@/lib/better-auth'; import { useState } from 'react'; export default function SignIn() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [loading, setLoading] = useState(false); const [error, setError] = useState(''); const handleCredentialsLogin = async (e: React.FormEvent) => { e.preventDefault(); setLoading(true); setError(''); try { const result = await signIn.email({ email, password, }); if (result.error) { setError(result.error.message || 'Invalid credentials'); } else { window.location.href = '/'; } } catch (err) { setError('Login failed'); } finally { setLoading(false); } }; const handleSocialSignIn = async (provider: 'github' | 'google') => { try { await signIn.social({ provider, callbackURL: '/', }); } catch (err) { setError(`Failed to sign in with ${provider}`); } }; return (
Sign in to your account
{error && (Don't have an account?{' '} Sign up