Log-out Customer in Storefront

In this document, you'll learn how to log-out a customer in the storefront based on the authentication method.

Log-Out for JWT Token#

If you're authenticating the customer with their JWT token, remove the stored token from the browser.

For example, if you've stored the JWT token in the localStorage, remove the item from it:

Code
localStorage.removeItem(`token`)

If you're authenticating the customer with their cookie session ID, send a DELETE request to the /auth/session.

For example:

The API route returns nothing in the response. If the request was successful, you can perform any necessary work to unset the customer and redirect them to the login page.

Was this page helpful?
Edit this page
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break