Store Hooks - Admin Components

Note: These hooks are available since Medusa v2.21.0.

The store hooks retrieve the active store from the Medusa backend, including its supported currencies and default sales channel.

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

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


useStore#

Retrieve the active store. The hook lists the stores and returns the first one, so it doesn't accept an ID.

Code
1const { store, isPending } = useStore({2  fields: "+supported_currencies.*",3})

Parameters#

Loading...
Warning: The request throws a 404 error when the Medusa backend has no store.

Returns#

Along with the following, the hook returns the rest of TanStack Query's useQuery result.

Loading...

storeQueryKeys#

storeQueryKeys is the query key factory for store queries. useStore registers its data under storeQueryKeys.details().

Use it to invalidate the cached store after a custom mutation:

Code
1import { useQueryClient } from "@tanstack/react-query"2import { storeQueryKeys } from "@medusajs/dashboard/hooks"3
4const queryClient = useQueryClient()5
6queryClient.invalidateQueries({7  queryKey: storeQueryKeys.details(),8})
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
⇧↵