Skip to main content
Glama
page.tsx2.96 kB
"use client"; import { useState } from 'react'; import { signIn } from 'next-auth/react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { Button } from '@repo/ui/button'; import { Card } from '@repo/ui/card'; export default function LoginPage() { const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [error, setError] = useState(''); const [isLoading, setIsLoading] = useState(false); const router = useRouter(); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); setError(''); setIsLoading(true); try { const result = await signIn('credentials', { redirect: false, email, password, }); if (result?.error) { setError('Invalid email or password'); } else { router.push('/dashboard'); } } catch (error) { setError('An error occurred. Please try again.'); } finally { setIsLoading(false); } }; return ( <div className="flex justify-center items-center min-h-[calc(100vh-200px)]"> <Card className="w-full max-w-md p-8"> <h1 className="text-2xl font-bold mb-6 text-center">Sign In</h1> {error && ( <div className="mb-4 p-3 bg-red-100 text-red-700 rounded-md"> {error} </div> )} <form onSubmit={handleSubmit} className="space-y-4"> <div> <label htmlFor="email" className="block text-sm font-medium mb-1"> Email </label> <input id="email" type="email" value={email} onChange={(e) => setEmail(e.target.value)} className="w-full p-2 border rounded focus:ring-2 focus:ring-blue-500 focus:outline-none dark:bg-gray-800" required /> </div> <div> <label htmlFor="password" className="block text-sm font-medium mb-1"> Password </label> <input id="password" type="password" value={password} onChange={(e) => setPassword(e.target.value)} className="w-full p-2 border rounded focus:ring-2 focus:ring-blue-500 focus:outline-none dark:bg-gray-800" required /> </div> <Button type="submit" variant="default" className="w-full" disabled={isLoading} > {isLoading ? 'Signing in...' : 'Sign In'} </Button> </form> <div className="mt-6 text-center"> <p> Don't have an account?{' '} <Link href="/register" className="text-blue-500 hover:underline"> Register </Link> </p> </div> </Card> </div> ); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/thomasdavis/blah'

If you have feedback or need assistance with the MCP directory API, please join our Discord server