@napps/nodes. Use them only inside a React UI component created by BaseReactUIComponent or createReactUIComponent.
Runtime and context hooks
useComponentRuntime
Returns the complete runtime value:
useComponentContext
Returns the native ComponentContext. Use it when a component needs context services such as product cards or component lifecycle operations.
useComponentArgs<TSettings>
Returns the component arguments, including the optional identifier, package name, and settings:
useComponentSettings<TSettings>
Returns args.settings directly. It is undefined when no settings were provided.
Event hooks
useComponentEvent
Subscribes to a named native component event and calls the latest callback without resubscribing on every render. The returned subscription is cleaned up automatically.
useComponentEventState
Stores the latest payload for a named event and returns it as React state:
null by default, until the event fires.
Product and PDP hooks
useSelectedProperties
Tracks selectedPropertiesUpdated events. The value includes selected option values, the matching variant when available, and the quantity added to cart.
useProductInfo
Tracks productInfoChanged events and returns the latest product information payload.
usePreferredStoresChanged
Calls a callback when the preferred store IDs change:
Product card hook
useProductCards
Provides the product window for a product-card-extension:
products: products in native display order.loadingCount: placeholder slots that must be rendered after real products.surface: the current surface name, ornullwhen no card bridge is attached.
Hook best practices
- Call hooks at the top level of a component.
- Keep event callbacks lightweight and update React state instead of mutating native nodes directly.
- Render nothing when
useProductCards().surfaceisnull. - Render
loadingCountskeletons after real product cards. - Clean up custom subscriptions in
useEffectwhen they are not managed by an Expresso hook.