signOut ends the user’s session by clearing their session cookie and redirecting them to the WorkOS logout URL. This function is typically used in server actions or route handlers.
Usage
Signature
Parameters
Configuration options for signing out.
Returns
This function never returns as it always redirects. It has a return type ofPromise<never>.
Examples
Basic sign-out button
Sign out with custom redirect
Sign out from a server action
Sign out and return to home page
Sign out with analytics tracking
Sign out from multiple pages
Notes
signOutalways triggers a redirect and never returns normally- The session cookie is deleted before redirecting
- If the
returnToparameter is not provided, the user is redirected to the default Logout URI configured in your WorkOS dashboard settings - This function can be called from anywhere authentication is not required (it works without middleware)
- The function will still work even if it cannot determine the session ID, falling back to a simple redirect