DEV Community

Alex Spinov
Alex Spinov

Posted on

Convex Has a Free Reactive Backend That Syncs Data to Your Frontend in Real-Time

Convex is a reactive backend-as-a-service. Define your backend in TypeScript — it auto-syncs to your frontend in real-time.

Free Tier

  • Unlimited API calls (within reason)
  • 512MB database
  • 1GB file storage
  • Scheduled functions — cron jobs
  • Full-text search — built-in
  • Real-time — automatic sync

Define Backend

// convex/messages.ts
import { query, mutation } from './_generated/server';
import { v } from 'convex/values';

export const list = query(async ({ db }) => {
  return await db.query('messages').order('desc').take(50);
});

export const send = mutation({
  args: { body: v.string(), author: v.string() },
  handler: async ({ db }, { body, author }) => {
    await db.insert('messages', { body, author });
  },
});
Enter fullscreen mode Exit fullscreen mode

Frontend (React)

const messages = useQuery(api.messages.list);
// Auto-updates when data changes!
Enter fullscreen mode Exit fullscreen mode

Convex vs Firebase

Feature Convex Firebase
Backend logic TypeScript functions Cloud Functions
Type safety Full Manual
Real-time Automatic onSnapshot
Database Relational-ish NoSQL

Need reactive backend? GitHub or spinov001@gmail.com

Top comments (0)