The onLogout
function performs a server action to log out a authenticated user. It is part of the @faustwp/experimental-app-router
package.
Here is an example action to log out an existing user that had previously been authenticated:
'use client'
import { onLogout } from '@faustwp/experimental-app-router';
<form action={onLogout}>
<button type="submit">Logout</button>
</form>;
onLogout()
This function does not accept any arguments.
If the form submission is successful, the server will remove the session cookie that is used to maintain the authentication status.