Skills.MD
# 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
评论 0
还没有评论,来抢沙发。
相关内容
同类或同场景的收录内容
building-with-kafka-strimzi
在 Kubernetes 上构建基于 Apache Kafka 的事件驱动系统,支持高可靠的消息传递、事务性处理与精确一次语义,结合 Strimzi 运营商实现集群自动化管理,利用 Schema Registry 保障事件模式演进,适用于微服务间解耦通信与实时数据流处理场景。
站外数据与分析
609 0.0
personal-tool-builder
专注于从个人真实痛点出发快速构建实用工具,涵盖命令行程序、本地优先应用和自动化脚本的开发与演进,强调先满足自身需求再逐步扩展,通过持续自用打磨功能,避免过度设计,确保工具简洁有效且长期可维护。
站外商业与营销
196 0.0
threejs-lighting
实现三维场景中的光照与阴影控制,支持多种光源类型及环境光照明,提供从基础布光到高级阴影优化的完整方案,适用于需要真实感渲染或性能平衡的可视化项目。
站外效率工具
442 0.0
aggregation-helper
提供数据聚合场景的自动化辅助能力,涵盖 SQL 查询编写、统计分析建模、可视化方案设计及商业智能配置,支持从需求理解到生产级代码生成的全流程指导。
站外效率工具数据与分析
217 0.0
举报「moai-platform-convex」
举报信息仅审核团队可见,同一资产 24 小时内仅可举报一次