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.

Code
1import {2  regionsQueryKeys,3  useRegion,4  useRegions,5} from "@medusajs/dashboard/hooks"

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


useRegion#

Fetches a single region by ID.

Code
1const { region, isPending } = useRegion(regionId, {2  fields: "+countries.*",3})

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.

Code
const { regions, count } = useRegions({ limit: 20 })

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

Code
1import { 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?
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
⇧↵