Raw
1 ---
2 sidebar_label: "Hooks"
3 ---
4
5 import { CardList } from "docs-ui"
6
7 export const metadata = {
8 title: `Hooks - Admin Components`,
9 }
10
11 # {metadata.title}
12
13 <Note>
14
15 These hooks are available since Medusa [v2.21.0](https://github.com/medusajs/medusa/releases/tag/v2.21.0).
16
17 </Note>
18
19 The `@medusajs/dashboard/hooks` subpath exports the React hooks that the Medusa Admin uses to fetch data and build its UI. Use them in your [widgets](!docs!/learn/fundamentals/admin/widgets) and [UI routes](!docs!/learn/fundamentals/admin/ui-routes).
20
21 ```tsx
22 import { useProducts } from "@medusajs/dashboard/hooks"
23 ```
24
25 <Note title="Tip">
26
27 Refer to the [Components reference](../components/page.mdx) for the components that pair with these hooks.
28
29 </Note>
30
31 ---
32
33 ## API Hooks
34
35 Use these hooks to fetch or mutate data from the Medusa backend. They are built on [TanStack Query](https://tanstack.com/query/latest) and follow the same patterns used throughout the Medusa Admin.
36
37 Each resource also exports a query key factory, which you use to invalidate the resource's cached queries after a mutation.
38
39 <CardList items={[
40 {
41 title: "Customers",
42 href: "/admin-components/hooks/customers",
43 },
44 {
45 title: "Orders",
46 href: "/admin-components/hooks/orders",
47 },
48 {
49 title: "Products",
50 href: "/admin-components/hooks/products",
51 },
52 {
53 title: "Product Variants",
54 href: "/admin-components/hooks/product-variants",
55 },
56 {
57 title: "Promotions",
58 href: "/admin-components/hooks/promotions",
59 },
60 {
61 title: "Regions",
62 href: "/admin-components/hooks/regions",
63 },
64 {
65 title: "Sales Channels",
66 href: "/admin-components/hooks/sales-channels",
67 },
68 {
69 title: "Shipping Options",
70 href: "/admin-components/hooks/shipping-options",
71 },
72 {
73 title: "Price Preferences",
74 href: "/admin-components/hooks/price-preferences",
75 },
76 {
77 title: "Store",
78 href: "/admin-components/hooks/store",
79 },
80 {
81 title: "Users",
82 href: "/admin-components/hooks/users",
83 },
84 ]} />
85
86 ---
87
88 ## Utility Hooks
89
90 <CardList items={[
91 {
92 title: "useComboboxData",
93 href: "/admin-components/hooks/use-combobox-data",
94 },
95 {
96 title: "useDate",
97 href: "/admin-components/hooks/use-date",
98 },
99 {
100 title: "useDebouncedSearch",
101 href: "/admin-components/hooks/use-debounced-search",
102 },
103 {
104 title: "useQueryParams",
105 href: "/admin-components/hooks/use-query-params",
106 },
107 {
108 title: "Data Table Hooks",
109 href: "/admin-components/hooks/data-table-helpers",
110 },
111 ]} />