Skip to content

vexConvexApi

const vexConvexApi: object

Defined in: packages/core/src/api/convex.ts:265

Typed anyApi references to the VexCMS generic Convex collection functions.

These point to functions that users copy into convex/vex/collections.ts in their project. All paths are fixed under vex.collections.*.

Required: copy convex/vex/collections.ts from the VexCMS template into your project before these references will resolve at runtime.

Used internally by view components in @vexcms/react. Framework adapter authors do not need to import this directly unless building custom views.

readonly create: FunctionReference<"mutation", "public", VexCreateArgs, string>

Creates a new document. Returns the new document’s ID as a string.

readonly find: FunctionReference<"query", "public", VexFindArgs, VexDocument[] | PaginationResult<VexDocument>>

Finds documents in a collection. Called by react/src!CollectionListView in @vexcms/react.

readonly findPaginated: FunctionReference<"query", "public", VexFindPaginatedArgs, PaginationResult<VexDocument>>

Finds documents in a collection with cursor pagination. Called by react/src!CollectionListView in @vexcms/react.

readonly get: FunctionReference<"query", "public", VexGetArgs, VexDocument | null>

Fetches a single document by ID. Called by react/src!CollectionEditView in @vexcms/react when editing.

readonly globals: object

readonly find: FunctionReference<"query", "public", VexGlobalsFindArgs, VexDocumentGlobal<string>[]>

readonly get: FunctionReference<"query", "public", VexGlobalsGetArgs, VexDocumentGlobal<string> | null>

readonly upsert: FunctionReference<"mutation", "public", VexGlobalsUpdateArgs, string>

readonly media: object

readonly createMediaDocument: FunctionReference<"mutation", "public", VexMediaCreateMediaDocumentArgs, string>

Creates a media document in Convex after the file is uploaded. Called by MediaUploadDropzone in @vexcms/react.

readonly deleteMedia: FunctionReference<"mutation", "public", VexMediaDeleteMediaArgs, boolean>

Deletes a media document and its file from storage. Called by MediaLibrary in @vexcms/react.

readonly generateUploadUrl: FunctionReference<"mutation", "public", VexMediaGenerateUploadUrlArgs, VexMediaGenerateUploadUrlReturn>

Generates a URL to upload a file to. Called by MediaUploadDropzone in @vexcms/react.

readonly getUrl: FunctionReference<"query", "public", VexMediaGetUrlArgs, VexMediaGetUrlReturn>

Returns a URL for a media file. Called by UploadFieldCell in @vexcms/react.

readonly remove: FunctionReference<"mutation", "public", VexRemoveArgs, void>

Permanently deletes a document.

readonly search: FunctionReference<"query", "public", VexSearchArgs, VexDocument[] | PaginationResult<VexDocument>>

Searches documents in a collection by a search index.

Used by RelationshipFieldInput in @vexcms/react to populate the relationship picker combobox. The searchIndexName must match the .searchIndex() name in the Convex schema — VexCMS auto-generates search_<useAsTitle> when another collection has a relationship here. Pass query: "" to list recent documents when no search term is entered.

https://docs.convex.dev/text-search for Convex search docs

readonly update: FunctionReference<"mutation", "public", VexUpdateArgs, void>

Patches an existing document — unspecified fields are left unchanged.

import { convexQuery } from "@convex-dev/react-query";
import { useQuery } from "@tanstack/react-query";
import { vexConvexApi } from "@vexcms/core";
const { data } = useQuery({
...convexQuery(vexConvexApi.list, { collection: "posts" }),
});