Files
vercel__next.js/examples/with-supabase/components/auth-button.tsx
Stojan Dimitrovski 8659d47c09 chore: Update with-supabase example to use getClaims() (#81383)
Updates the `with-supabase` example to use the new and much faster (when
project is configured with asymmetric JWT support)
`supabase.auth.getClaims()` function instead of `getUser()`.

---------

Co-authored-by: Benjamin Woodruff <benjamin.woodruff@vercel.com>
2025-07-15 15:31:46 -07:00

30 lines
805 B
TypeScript

import Link from "next/link";
import { Button } from "./ui/button";
import { createClient } from "@/lib/supabase/server";
import { LogoutButton } from "./logout-button";
export async function AuthButton() {
const supabase = await createClient();
// You can also use getUser() which will be slower.
const { data } = await supabase.auth.getClaims();
const user = data?.claims;
return user ? (
<div className="flex items-center gap-4">
Hey, {user.email}!
<LogoutButton />
</div>
) : (
<div className="flex gap-2">
<Button asChild size="sm" variant={"outline"}>
<Link href="/auth/login">Sign in</Link>
</Button>
<Button asChild size="sm" variant={"default"}>
<Link href="/auth/sign-up">Sign up</Link>
</Button>
</div>
);
}