Logout User

Logs the current user out of the app.

Description

The logoutUser() action logs the current customer out of the app and clears the authenticated session.

Function Signature

await Superfans.actions.logoutUser();
ParameterTypeRequiredDescription
NilNilNilThis action does not require any parameter.

Structure of Response

StatusResponse
Success{ "status": "success", "message": "User logged out successfully" }
Unexpected Error{ "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" }

Example Usage

await Superfans.actions.logoutUser();

Best Practices

  1. Use this from a logout button on account or profile screens.
  2. Listen to Superfans.listeners.onLoginStatusChanged and re-read Superfans.variables.customer after logout.

Caveats

  1. This action ends the current customer session; wishlist and account data will no longer be available until the user logs in again.
  2. Cart behavior after logout depends on the app configuration.

Did this page help you?