Semantics of GET
v DELETE
for Logging Out
#57991
-
I have a client component ( {/**
* Although it would be more semantically correct to use `POsT` or `DELETE` to affect the log out,
* NextJS docs 📝 say,
* "Use the `<Link>` component for navigation unless you have a specific requirement for using `useRouter.`"
* @see https://nextjs.org/docs/app/api-reference/functions/use-router
*
* So, semantics be darned, this is more idiomatic NextJS and less code.
*/}
<NavLink href="/api/logout">
<ExitIcon />
Logout
</NavLink> That works. ☝️ I'm just a little bothered by violating REST conventions/semantics! Alternatively, to be semantically correct, I would use an In other words, to be semantically correct adds a lot more code. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Or... <form method="post" action="/api/logout">
<button type="submit">
<ExitIcon />
</button>
</form> |
Beta Was this translation helpful? Give feedback.
Or...