Promotion Hooks - Admin Components
Note: These hooks are available since Medusa v2.21.0.
The promotion hooks fetch promotions from the Medusa backend. Use them to show promotion data in your admin customizations.
These hooks are built on TanStack Query. Use them in your widgets and UI routes.
usePromotions#
Fetches a paginated list of promotions.
Parameters#
Loading...
Returns
Along with the following, the hook returns the rest of TanStack Query's useQuery result.
Loading...
promotionsQueryKeys#
A TanStack Query key factory for promotion queries. Besides all, lists(), list(query), details(), and detail(id, query), it adds the promotion-specific keys listRules(id, ruleType, query), listRuleAttributes(ruleType, promotionType, applicationMethodTargetType), and listRuleValues(ruleType, ruleValue, query).
1import { useQueryClient } from "@tanstack/react-query"2import {3 promotionsQueryKeys,4} from "@medusajs/dashboard/hooks"5 6const Widget = () => {7 const queryClient = useQueryClient()8 9 const refreshPromotions = () => {10 queryClient.invalidateQueries({11 queryKey: promotionsQueryKeys.lists(),12 })13 }14 15 // ...16}
Was this page helpful?