openLoginModal(): Promise<void>¶
The openLoginModal is an asynchronous method that allows to open a modal with the login form inside.
Returned value¶
A returned value has a type of Promise<void> because of potential additional animations and transitions occurring while opening a modal.
Event Bus events¶
This API method dispatches the following events with the Event Bus:
- FlashMessengerApi.addFlashMessage - when the user is already logged in while opening a modal
- authentication.authorized - when the user is already authorized while opening a modal
Example¶
In this example we make a AuthenticationApi call to open a login modal.
useStorefront(async (storefront) => {
const authenticationApi = await storefront.getApi('AuthenticationApi');
await authenticationApi.openLoginModal();
});