Skip to main content
@repo/backend runs your database, serverless functions, scheduled jobs, and webhook handlers on Convex.

Schema

Define tables in a single file:
packages/backend/convex/schema.ts
import { defineSchema, defineTable } from "convex/server";
import { v } from "convex/values";

export default defineSchema({
  users: defineTable({
    clerkId: v.string(),
    email: v.string(),
    name: v.optional(v.string()),
  }).index("by_clerk_id", ["clerkId"]),
});

Usage

Convex uses file-based routing. A function in convex/chat/streaming.ts becomes api.chat.streaming:
apps/app/components/chat.tsx
import { api } from "@repo/backend";
import { useAction } from "convex/react";

const streamChat = useAction(api.chat.streaming.send);

Webhooks

Inbound webhooks from Clerk, Stripe, and Resend route through convex/http.ts:
packages/backend/convex/http.ts
import { httpRouter } from "convex/server";

const http = httpRouter();

http.route({
  path: "/clerk",
  method: "POST",
  handler: clerkWebhook,
});

Commands

CommandPurpose
bunx convex devStart local dev server
bunx convex deployDeploy to production
All Convex functions require argument and return validators. Omitting them causes type errors and deployment failures.

Learn More