Skip to main content
Skip to main content

Stores

Queries and Mutations listed here are used to send requests to the Admin Store API Routes.

All hooks listed require user authentication.

A store indicates the general configurations and details about the commerce store. By default, there's only one store in the Medusa backend. Admins can manage the store and its details or configurations.

Mutations

useAdminUpdateStore

This hook updates the store's details.

Example

import React from "react"
import { useAdminUpdateStore } from "medusa-react"

function Store() {
const updateStore = useAdminUpdateStore()
// ...

const handleUpdate = (
name: string
) => {
updateStore.mutate({
name
}, {
onSuccess: ({ store }) => {
console.log(store.name)
}
})
}
}

export default Store

Mutation Function Parameters

AdminPostStoreReqAdminPostStoreReqRequired
The details to update of the store.

Mutation Function Returned Data

AdminStoresResAdminStoresResRequired
The store's details.

useAdminAddStoreCurrency

This hook adds a currency code to the available currencies in a store. This doesn't create new currencies, as currencies are defined within the Medusa backend. To create a currency, you can create a migration that inserts the currency into the database.

Example

import React from "react"
import { useAdminAddStoreCurrency } from "medusa-react"

const Store = () => {
const addCurrency = useAdminAddStoreCurrency()
// ...

const handleAdd = (code: string) => {
addCurrency.mutate(code, {
onSuccess: ({ store }) => {
console.log(store.currencies)
}
})
}

// ...
}

export default Store

Mutation Function Parameters

stringstringRequired
The code of the currency to add to the store.

Mutation Function Returned Data

AdminStoresResAdminStoresResRequired
The store's details.

useAdminDeleteStoreCurrency

This hook deletes a currency code from the available currencies in a store. This doesn't completely delete the currency and it can be added again later to the store.

Example

import React from "react"
import { useAdminDeleteStoreCurrency } from "medusa-react"

const Store = () => {
const deleteCurrency = useAdminDeleteStoreCurrency()
// ...

const handleAdd = (code: string) => {
deleteCurrency.mutate(code, {
onSuccess: ({ store }) => {
console.log(store.currencies)
}
})
}

// ...
}

export default Store

Mutation Function Parameters

stringstringRequired
The code of the currency to remove from the store.

Mutation Function Returned Data

AdminStoresResAdminStoresResRequired
The store's details.

Queries

useAdminStorePaymentProviders

This hook retrieves a list of available payment providers in a store.

Example

import React from "react"
import { useAdminStorePaymentProviders } from "medusa-react"

const PaymentProviders = () => {
const {
payment_providers,
isLoading
} = useAdminStorePaymentProviders()

return (
<div>
{isLoading && <span>Loading...</span>}
{payment_providers && !payment_providers.length && (
<span>No Payment Providers</span>
)}
{payment_providers &&
payment_providers.length > 0 &&(
<ul>
{payment_providers.map((provider) => (
<li key={provider.id}>{provider.id}</li>
))}
</ul>
)}
</div>
)
}

export default PaymentProviders

Query Returned Data

payment_providersPaymentProvider[]Required
An array of payment providers details.

useAdminStoreTaxProviders

This hook retrieves a list of available tax providers in a store.

Example

import React from "react"
import { useAdminStoreTaxProviders } from "medusa-react"

const TaxProviders = () => {
const {
tax_providers,
isLoading
} = useAdminStoreTaxProviders()

return (
<div>
{isLoading && <span>Loading...</span>}
{tax_providers && !tax_providers.length && (
<span>No Tax Providers</span>
)}
{tax_providers &&
tax_providers.length > 0 &&(
<ul>
{tax_providers.map((provider) => (
<li key={provider.id}>{provider.id}</li>
))}
</ul>
)}
</div>
)
}

export default TaxProviders

Query Returned Data

tax_providersTaxProvider[]Required
An array of tax providers details.

useAdminStore

This hook retrieves the store's details.

Example

import React from "react"
import { useAdminStore } from "medusa-react"

const Store = () => {
const {
store,
isLoading
} = useAdminStore()

return (
<div>
{isLoading && <span>Loading...</span>}
{store && <span>{store.name}</span>}
</div>
)
}

export default Store

Query Returned Data

storeExtendedStoreDTORequired
Store details.
Was this section helpful?