Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

adds react-query prefetch docs

Alaister Youngc2077c9c251c
diff --git a/studio/data/__templates/resource-query.ts b/studio/data/__templates/resource-query.ts
index c348077547f..6d278c48ceb 100644
--- a/studio/data/__templates/resource-query.ts
+++ b/studio/data/__templates/resource-query.ts
@@ -47,6 +47,18 @@ export const useResourceQuery = <TData = ResourceData>(
}
)
+/**
+ * useResourcePrefetch is used for prefetching data. For example, starting a query loading before a page is navigated to.
+ *
+ * @example
+ * const prefetch = useResourcePrefetch({ projectRef, id })
+ *
+ * return (
+ * <Link onMouseEnter={() => prefetch()}>
+ * Start loading on hover
+ * </Link>
+ * )
+ */
export const useResourcePrefetch = ({ projectRef, id }: ResourceVariables) => {
const client = useQueryClient()
diff --git a/studio/data/__templates/resources-query.ts b/studio/data/__templates/resources-query.ts
index 9ff95df37f7..b9b1ae01a68 100644
--- a/studio/data/__templates/resources-query.ts
+++ b/studio/data/__templates/resources-query.ts
@@ -40,6 +40,18 @@ export const useResourcesQuery = <TData = ResourcesData>(
{ enabled: enabled && typeof projectRef !== 'undefined', ...options }
)
+/**
+ * useResourcesPrefetch is used for prefetching data. For example, starting a query loading before a page is navigated to.
+ *
+ * @example
+ * const prefetch = useResourcesPrefetch({ projectRef })
+ *
+ * return (
+ * <Link onMouseEnter={() => prefetch()}>
+ * Start loading on hover
+ * </Link>
+ * )
+ */
export const useResourcesPrefetch = ({ projectRef }: ResourcesVariables) => {
const client = useQueryClient()
diff --git a/studio/data/table-rows/table-rows-count-query.ts b/studio/data/table-rows/table-rows-count-query.ts
index 265aa2c4bf5..bb3e504c667 100644
--- a/studio/data/table-rows/table-rows-count-query.ts
+++ b/studio/data/table-rows/table-rows-count-query.ts
@@ -66,6 +66,18 @@ export const useTableRowsCountQuery = <TData extends TableRowsCountData = TableR
}
)
+/**
+ * useTableRowsCountPrefetch is used for prefetching the table rows count. For example, starting a query loading before a page is navigated to.
+ *
+ * @example
+ * const prefetch = useTableRowsCountPrefetch({ ...args })
+ *
+ * return (
+ * <Link onMouseEnter={() => prefetch()}>
+ * Start loading on hover
+ * </Link>
+ * )
+ */
export const useTableRowsCountPrefetch = ({
projectRef,
connectionString,
diff --git a/studio/data/table-rows/table-rows-query.ts b/studio/data/table-rows/table-rows-query.ts
index 61078b80b84..edbf5155767 100644
--- a/studio/data/table-rows/table-rows-query.ts
+++ b/studio/data/table-rows/table-rows-query.ts
@@ -97,6 +97,18 @@ export const useTableRowsQuery = <TData extends TableRowsData = TableRowsData>(
}
)
+/**
+ * useTableRowsPrefetch is used for prefetching table rows. For example, starting a query loading before a page is navigated to.
+ *
+ * @example
+ * const prefetch = useTableRowsPrefetch({ projectRef })
+ *
+ * return (
+ * <Link onMouseEnter={() => prefetch()}>
+ * Start loading on hover
+ * </Link>
+ * )
+ */
export const useTableRowsPrefetch = ({
projectRef,
connectionString,