"use client";
import { useRouter } from "next/navigation";
import { signInWithEmailAndPassword } from "firebase/auth";
import PullCordLogin from "@/components/PullCordLogin";
import { auth } from "@/lib/firebase";
export default function LoginPage() {
const router = useRouter();
return (
<main className="grid min-h-dvh place-items-center overflow-hidden bg-[#07080c]">
<PullCordLogin
defaultOn
subtitle="Sign in to your account"
forgotHref="/reset-password"
onFooterAction={() => router.push("/signup")}
onSubmit={async (email, password) => {
// A rejected promise makes the card shake; a resolved one shows the success label.
await signInWithEmailAndPassword(auth, email, password);
setTimeout(() => router.push("/dashboard"), 900);
}}
/>
</main>
);
}
lib/firebase.ts
import { getApp, getApps, initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";
const firebaseConfig = {
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
};
// Reuse the app on hot reload instead of initializing it twice.
export const app = getApps().length ? getApp() : initializeApp(firebaseConfig);
export const auth = getAuth(app);
Good to know
onSubmit waits for your promise. signInWithEmailAndPassword throws on a wrong password, so the card shakes and the button resets. The piece doesn't print the error text, so add your own line under it if you want to show Firebase's message.
defaultOn shows the card straight away. Leave it off if you want visitors to pull the cord first, but then a returning user has to find the cord to sign in.
The room is drawn at 1000 x 660. On small screens, scale it with the className or style props.
This signs the user in on the client. To protect server routes, check the session server-side as Firebase's docs describe; that part isn't in the piece.
Install
Copy from the zipPut react/src/components into src/, then npm i framer-motion firebase.
Or ask your AIPaste PROMPT.md into Cursor, Lovable or v0.