Alokai
You are reading the documentation for SDK v2, which is no longer the latest version. Switch to current

isLoggedIn

Method for checking if the user is logged in.

This method sends a POST request to the isLoggedIn endpoint. Method verifies if the user is logged in by checking if the vsf-commercetools-token cookie is set.

Signature

export declare function isLoggedIn(
	options?: MethodBaseOptions
): Promise<IsLoggedInResponse>;

Parameters

NameRequiredTypeDescription
optionsOptionalMethodBaseOptionsMethod options

Returns

Returns a representation of the IsLoggedInResponse.

Referenced Types

Examples

Check if the user is logged in:

import { sdk } from '~/sdk.config.ts';

const { value } = await sdk.commerce.isLoggedIn();
if (value) {
 // User is logged in
}

On this page