Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Why not using signOut? #43

Unanswered
engin-can asked this question in Q&A
Discussion options

I was wondering why you are not using signOut from @auth here. Is there something wrong with it?

"use client";
import type { CollectionSlug } from "payload";
export function SignOutButton({
 userCollectionSlug = "users",
}: {
 userCollectionSlug?: CollectionSlug;
}) {
 return (
 <button
 type="button"
 onClick={async () => {
 await fetch(`/api/${userCollectionSlug}/logout`, {
 method: "POST",
 headers: {
 "Content-Type": "application/json",
 },
 });
 window.location.reload();
 }}
 >
 Sign Out
 </button>
 );
}

https://github.com/CrawlerCode/payload-authjs/blob/c064b334161d942efadcd4e96f484bcfe6343ac0/examples/basic/src/app/(app)/_components/SignOutButton.tsx#L13C7-L22C6

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /