@lucia-auth/nextjs
Version:
Lucia integration for Next.js
19 lines (18 loc) • 495 B
JavaScript
export const getUser = async () => {
const response = await fetch("/api/auth/user");
if (!response.ok)
return null;
const { user } = (await response.json());
return user;
};
export const signOut = async () => {
const response = await fetch("/api/auth/logout", {
method: "POST"
});
if (!response.ok)
throw new Error("unknown error");
const { error } = (await response.json());
if (!error)
return;
throw new Error(error);
};