Skip to content

Engine: Wishlist

The server-backed wishlist: WishlistProvider and useWishlistContext.

Generated from packages/engine/src/wishlist/: 1 files, 6 exported symbols. Signatures and types are shown as written in the source.

@magenxcommerce/engine/wishlist/wishlist-context

packages/engine/src/wishlist/wishlist-context.tsxclient

WISHLIST_STORAGE_KEY const

const WISHLIST_STORAGE_KEY = "magenx_wishlist"

localStorage key for the guest (logged-out) wishlist mirror.

WishlistEntry interface

Normalized wishlist line shared by both guest (localStorage) and customer (Magento GraphQL) modes. Membership is keyed on sku — the stable cross-system identifier, since Magento's wishlist is sku-based. In customer mode wishlistItemId is set and used for removal (Magento removes by item id, not sku).

MemberTypeDescription
skustring
wishlistItemId?string
namestring
url_keystring
image_url?string
price?number
currency?string
stock_status?"IN_STOCK" | "OUT_OF_STOCK"

WishlistProduct interface

Minimal product shape needed to save an item (a ProductInterface satisfies it).

MemberTypeDescription
skustring
namestring
url_keystring
uid?string
stock_status?"IN_STOCK" | "OUT_OF_STOCK"
image?{ url?: string | null } | null
price_range?{ minimum_price?: { final_price?: { value?: number; currency?: string } | null; } | null; } | null

WishlistContextValue interface

MemberTypeDescription
itemsWishlistEntry[]
countnumber
loadingboolean
hydratedbooleanTrue once client storage has been read — avoids SSR hydration mismatch.
isInWishlist(sku: string) => boolean
add(product: WishlistProduct) => Promise<{ error?: string }>
remove(sku: string) => Promise<void>
toggle(product: WishlistProduct, event?: ReactMouseEvent) => void

WishlistProvider function

WishlistProvider({ children }: { children: ReactNode })

useWishlistContext function

useWishlistContext(): WishlistContextValue