Sales Channel Hooks - Admin Components
The sales channel hooks retrieve sales channels from the Medusa backend and manage the products linked to a sales channel.
These hooks are built on TanStack Query. Use them in your widgets and UI routes.
useSalesChannel#
Retrieve a single sales channel by its ID. The hook returns the sales channel along with the TanStack Query result properties.
Parameters#
Returns
Along with the following, the hook returns the rest of TanStack Query's useQuery result.
useSalesChannels#
Retrieve a paginated list of sales channels. Pass query parameters to filter or paginate the returned sales channels.
Parameters#
Returns#
Along with the following, the hook returns the rest of TanStack Query's useQuery result.
useSalesChannelAddProducts#
Add products to a sales channel. Pass the sales channel's ID to the hook, then pass an array of product IDs to mutate or mutateAsync.
Parameters
Returns#
Along with the following, the hook returns the rest of TanStack Query's useMutation result.
useSalesChannelRemoveProducts#
Remove products from a sales channel. It accepts the same parameters as useSalesChannelAddProducts, and the array passed to mutate holds the IDs of the products to remove.
Parameters#
Returns#
Along with the following, the hook returns the rest of TanStack Query's useMutation result.
salesChannelsQueryKeys#
is the query key factory for sales channel queries. Use , , , , and to build the keys that the hooks above register.
Use it to invalidate cached sales channel data after a custom mutation: