Skip to content

Logout

Destroy the user session and log them out of your application.

Within the form action, import createBlankSession

src/actions/auth.ts
"use server"
import { cookies } from "next/headers"
import { revalidatePath } from "next/cache"
import { createBlankSession } from "@/auth"
// Should be defined right after imports
const blankSession = createBlankSession()
// ..
export async function Logout() {
const cookieName = blankSession.name
cookies().delete(cookieName)
// revalidate the current page cache
revalidatePath("/")
}