Przejdź do głównej zawartości

Function: readCartCredentials()

readCartCredentials(): Promise<CartCredentials | null>

Read the cart-id cookie and split the composite <cartId>.<secret> value into { cartId, cartSecret }. Pass the result to serverCartSecretMiddleware so an SSR / edge cart read carries the secret (without it the backend treats the cart as unreachable and the read returns empty). Returns null when no cart cookie is present.

Returns

Promise<CartCredentials | null>

Example

import { getStorefrontClient } from '@doswiftly/storefront-sdk/react/server';
import { readCartCredentials, serverCartSecretMiddleware } from '@doswiftly/storefront-sdk/react/server';

const client = getStorefrontClient({
apiUrl, shopSlug,
middleware: [serverCartSecretMiddleware(await readCartCredentials())],
});