logout - JS SDK Auth Reference

This documentation provides a reference to the sdk.auth.logout method used to send requests to Medusa's Authentication API routes. It can be used for admin users, customers, or custom actor types.

This method logs out the currently authenticated user based on your JS SDK authentication configurations.

If the auth.type of the SDK is set to session, this method will also send a request to the Delete Authentication Session API route.

The method also clears any stored tokens or sessions, based on your JS SDK authentication configurations.

Learn more in the JS SDK Authentication guide.

Example#

Code
1await sdk.auth.logout()2
3// user is now logged out4// you can't send any requests that require authentication

Returns#

PromisePromise<void>
This method logs out the currently authenticated user based on your JS SDK authentication configurations. If the auth.type of the SDK is set to session, this method will also send a request to the Delete Authentication Session API route. The method also clears any stored tokens or sessions, based on your JS SDK authentication configurations. Learn more in the JS SDK Authentication guide.
Was this page helpful?
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