Stores
Queries and Mutations listed here are used to send requests to the Admin Store API Routes.
All hooks listed require 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
Mutation Function Parameters
The details to update of the store.
Mutation Function Returned Data
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
string
stringRequiredMutation Function Returned Data
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
string
stringRequiredMutation Function Returned Data
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
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
An array of tax providers details.
useAdminStore
This hook retrieves the store's details.