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.

Code
1import {2  promotionsQueryKeys,3  usePromotions,4} from "@medusajs/dashboard/hooks"

These hooks are built on TanStack Query. Use them in your widgets and UI routes.


usePromotions#

Fetches a paginated list of promotions.

Code
1const { promotions, count, isPending } = usePromotions({2  limit: 20,3})

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).

Code
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?
Ask Bloom
For assistance in your development, use Claude Code Plugins or Docs MCP server in Cursor, VSCode, etc...FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break
⇧↵