Stock Locations
Queries and Mutations listed here are used to send requests to the Admin Stock Location API Routes. To use these hooks, make sure to install the @medusajs/stock-location module in your Medusa backend.
All hooks listed require user authentication.
A stock location, provided by the Stock Location module, indicates a physical address that stock-kept items, such as physical products, can be stored in. An admin can create and manage available stock locations.
Related Guide: How to manage stock locations.
Mutations
useAdminCreateStockLocation
This hook creates a stock location.
Example
import React from "react"
import { useAdminCreateStockLocation } from "medusa-react"
const CreateStockLocation = () => {
const createStockLocation = useAdminCreateStockLocation()
// ...
const handleCreate = (name: string) => {
createStockLocation.mutate({
name,
}, {
onSuccess: ({ stock_location }) => {
console.log(stock_location.id)
}
})
}
// ...
}
export default CreateStockLocation