DEV Community

Alex Spinov
Alex Spinov

Posted on

Convex Has a Free API That Gives You a Reactive Backend With Real-Time Sync

Convex is a reactive backend: define your schema and queries in TypeScript, get real-time updates in your frontend automatically. No WebSocket setup, no polling.

Quick Start

npm create convex@latest
Enter fullscreen mode Exit fullscreen mode

Define Schema

// convex/schema.ts
import { defineSchema, defineTable } from 'convex/server'
import { v } from 'convex/values'

export default defineSchema({
  messages: defineTable({
    author: v.string(),
    body: v.string(),
  })
})
Enter fullscreen mode Exit fullscreen mode

Write Queries

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

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

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

Use in React (Real-Time!)

import { useQuery, useMutation } from 'convex/react'
import { api } from '../convex/_generated/api'

function Chat() {
  const messages = useQuery(api.messages.list)  // Auto-updates!
  const send = useMutation(api.messages.send)

  return (
    <div>
      {messages?.map(m => <p key={m._id}>{m.author}: {m.body}</p>)}
      <button onClick={() => send({ author: 'Me', body: 'Hello!' })}>Send</button>
    </div>
  )
}
Enter fullscreen mode Exit fullscreen mode

When anyone sends a message, ALL connected clients update instantly. No WebSocket code.

Free Tier

  • 100K function calls/month
  • 1M database reads/month
  • 1GB storage
  • Real-time sync included

The Bottom Line

Convex is the simplest path to a real-time backend. TypeScript end-to-end, reactive by default, generous free tier.


Need to automate data collection or build custom scrapers? Check out my Apify actors for ready-made tools, or email spinov001@gmail.com for custom solutions.

Top comments (0)