Moai Platform Convex

Convex real-time backend specialist covering TypeScript-first reactive patterns, optimistic updates, server functions, and file storage. Use when building real-time collaborative apps, implementing reactive queries, or integrating with Clerk/Auth0.

Published by modu-ai

Development

Cloud-native skill

Runs in the cloud

No local installation

Dependencies pre-installed

Ready to run instantly

Secure VM environment

Isolated per task

Works on any device

Desktop, tablet, or phone

Documentation

Convex Real-time Backend Specialist

Convex is a real-time reactive backend platform with TypeScript-first design, automatic caching, and optimistic updates.


Quick Reference

When to Use Convex

Use Convex for real-time collaborative applications including docs, whiteboards, and chat. Choose Convex for apps requiring instant UI updates without manual refetching. Select Convex for TypeScript-first projects needing end-to-end type safety. Use Convex for applications with complex optimistic update requirements.

Core Concepts

Server Functions include queries for read operations, mutations for write operations, and actions for external API calls.

Reactive Queries automatically re-execute when underlying data changes.

Optimistic Updates provide instant UI updates before server confirmation.

Automatic Caching provides built-in query result caching with intelligent invalidation.

Quick Start

Initialize a new Convex project using npm create convex@latest. Start the development server with npx convex dev.

Context7 Library

Use mcp__context7__resolve-library-id with "convex" to get the library ID, then use mcp__context7__get-library-docs for latest documentation.


Module Index

This skill is organized into specialized modules for detailed implementation guidance:

Reactive Queries Module

Location: modules/reactive-queries.md

Covers real-time reactive query patterns including basic query structure, index-based queries, search indexes, pagination patterns, React integration with useQuery hooks, and optimistic updates.

Server Functions Module

Location: modules/server-functions.md

Covers mutations for write operations, actions for external API integration, internal functions for server-to-server calls, scheduled functions using crons, and HTTP endpoints for webhooks.

Authentication Integration Module

Location: modules/auth-integration.md

Covers Clerk integration, Auth0 integration, server-side authentication patterns, authorization and role-based access control, and session management.

File Storage Module

Location: modules/file-storage.md

Covers file upload workflows, storage URL generation, client-side upload with progress, file display components, and file management operations.


Implementation Guide

Project Structure

A Convex project contains a convex directory with _generated subdirectory for auto-generated types and API, schema.ts for database schema definition, a functions subdirectory for server functions organized by domain, optional http.ts for HTTP endpoints, and optional crons.ts for scheduled jobs. The src directory contains ConvexProvider.tsx for client setup.

Schema Definition

The schema.ts file imports defineSchema and defineTable from convex/server and v from convex/values. The default export uses defineSchema to define tables. Each table is defined with defineTable specifying field types such as v.string(), v.boolean(), and v.number(). Tables can have indexes defined using the index method with index name and field array. Search indexes use the searchIndex method specifying searchField and filterFields.

Validators

The v module from convex/values provides primitive validators including v.string(), v.number(), v.boolean(), v.null(), v.int64(), and v.bytes().

Complex types include v.array() for arrays of a type, v.object() for objects with specified fields, v.union() for union types with v.literal() options, and v.optional() for optional fields.

Reference validators include v.id() for references to table documents.

React Client Setup

The ConvexProvider component imports ConvexProvider and ConvexReactClient from convex/react, ConvexProviderWithClerk from convex/react-clerk, and useAuth from @clerk/clerk-react. Create a ConvexReactClient instance with the VITE_CONVEX_URL environment variable. The Providers component wraps children with ConvexProviderWithClerk passing the client and useAuth hook.

React Hooks Usage

Import useQuery and useMutation from convex/react and api from the generated API module. In a component, call useQuery with the query function and parameters to get reactive data. Call useMutation to get a mutation function. Handle the undefined state during loading. Render the data and use the mutation function in event handlers.


Best Practices

Query Optimization:

  • Use indexes for all filtered queries
  • Prefer paginated queries for large datasets
  • Use search indexes for full-text search
  • Leverage automatic caching

Mutation Design:

  • Keep mutations focused and atomic
  • Use internal mutations for multi-step operations
  • Validate all inputs with the v module
  • Always check authorization

Error Handling:

  • Use ConvexError for structured errors
  • Check for undefined during loading states
  • Handle optimistic update rollbacks

Works Well With

  • moai-platform-supabase for alternative PostgreSQL-based backend
  • moai-lang-typescript for TypeScript patterns and best practices
  • moai-domain-frontend for React integration patterns
  • moai-platform-clerk for Clerk authentication patterns
  • moai-platform-auth0 for Auth0 authentication patterns

Resources

  • Official Documentation at docs.convex.dev
  • Context7 Library at /get-convex/convex
  • GitHub at github.com/get-convex/convex

Status: Production Ready Version: 2.1.0 Last Updated: 2026-01-11 Platform: Convex Real-time Backend

Skill as a Service

Everyone else asks you to install skills locally. On Rebyte, just click Run. Works from any device — even your phone. No CLI, no terminal, no configuration.

  • Zero setup required
  • Run from any device, including mobile
  • Results streamed in real-time
  • Runs while you sleep
Run this skill now

Compatible agents

Claude Code

Gemini CLI

Codex

Cursor, Windsurf, Amp

rebyte.ai — The only platform where you can run AI agent skills directly in the cloud

No downloads. No configuration. Just sign in and start using AI skills immediately.

Use this skill in Agent Computer — your shared cloud desktop with all skills pre-installed. Join Moltbook to connect with other teams.