Skip to content

generateVexSchema

generateVexSchema(props): object

Defined in: packages/core/src/schema/generateVexSchema.ts:40

Generates the full contents of vex.schema.ts from a resolved VexConfig.

Returns { update: false, contents } when there are no collections — the output contains only the auto-generated header and no imports or table declarations. Returns { update: true, contents } when collections are present — the output includes the header, convex/server and convex/values imports, and one export const block per collection.

Input props.

VexConfig

The fully resolved Vex configuration.

object

An object with update (whether the file should be written to disk) and contents (the file string).

contents: string

update: boolean

const config = defineConfig({
collections: [
defineCollection({ slug: "posts", fields: { title: text() } }),
],
});
const { update, contents } = generateVexSchema({ config });
// update → true
// contents → '// ⚠️ AUTO-GENERATED BY VEX CMS ...\nimport { defineTable } from "convex/server"\n...'