useLivePreviewQuery
useLivePreviewQuery<
TCollectionSlug,TQueryKey>(queryOptions,collectionSlug):LivePreviewQueryResult<TCollectionSlug>
Defined in: packages/react/src/livePreview/LivePreviewContext.tsx:350
Sugar composing useQuery with useLivePreview — shaped around a
getBySlug-style query that resolves to an array, narrowed to its first
element the same way PageContent.tsx already does by hand.
Type Parameters
Section titled “Type Parameters”TCollectionSlug
Section titled “TCollectionSlug”TCollectionSlug extends string = string
TQueryKey
Section titled “TQueryKey”TQueryKey extends readonly unknown[] = readonly unknown[]
Parameters
Section titled “Parameters”queryOptions
Section titled “queryOptions”UseQueryOptions<DocumentByResourceSlug<TCollectionSlug>[], Error, DocumentByResourceSlug<TCollectionSlug>[], TQueryKey>
The useQuery options for a query resolving to an array.
collectionSlug
Section titled “collectionSlug”TCollectionSlug
The collection those documents belong to.
Returns
Section titled “Returns”LivePreviewQueryResult<TCollectionSlug>
The query result with data narrowed to the single overlaid document.
Example
Section titled “Example”const { data: page } = useLivePreviewQuery( { ...convexQuery(api.pages.getBySlug, { slug }), initialData }, "pages",);