Region Hooks - Admin Components
Note: These hooks are available since Medusa v2.21.0.
The region hooks fetch regions from the Medusa backend. Use them to show or select regions in your admin customizations.
These hooks are built on TanStack Query. Use them in your widgets and UI routes.
useRegion#
Fetches a single region by ID.
Parameters#
Loading...
Returns
Along with the following, the hook returns the rest of TanStack Query's useQuery result.
Loading...
useRegions#
Fetches a paginated list of regions.
Parameters#
Loading...
Returns#
Along with the following, the hook returns the rest of TanStack Query's useQuery result.
Loading...
regionsQueryKeys#
A TanStack Query key factory for region queries. Use it to invalidate cached region data after you change a region.
It provides all, lists(), list(query), details(), and detail(id, query).
Code1import { useQueryClient } from "@tanstack/react-query"2import { regionsQueryKeys } from "@medusajs/dashboard/hooks"3 4const Widget = () => {5 const queryClient = useQueryClient()6 7 const refreshRegions = () => {8 queryClient.invalidateQueries({9 queryKey: regionsQueryKeys.lists(),10 })11 }12 13 // ...14}
Was this page helpful?