This article started as a talk. The code below comes from the small demo app I built for it, trimmed a little.
What Convex is
A Convex backend is a set of TypeScript functions. Every query and mutation is a transaction, and every query is a live subscription.
Everything else follows from that. You write a schema, queries, mutations and actions. The platform owns the transport, the cache, the subscriptions and the retries. There is no SQL, no ORM, no connection pool, and no socket code. The client holds one WebSocket and subscribes to a function, not to a table. When the data that function read changes, it runs again and pushes the new result.
The pain it removes
Convex is aimed at problems most web backends share.
- Stale UI. In a typical stack, REST reads from the database and realtime arrives on a separate channel. Two sources of truth, and the screen shows a mix of both. In Convex, the query and the subscription are the same thing.
- Races and double writes. Transactions are opt-in almost everywhere, and the retry loop is yours to write. In Convex there is nothing to opt into.
- Glue. An API layer, a cache, a job queue, a cron box and a socket server, each with its own deploy and its own way to fail. Here the scheduler, crons, file storage and search ship in the same deploy as the code.
- Types that stop at the API. A schema in the database, DTOs in the API, types on the client: three copies that drift. Here one
schema.tsproduces the types in the functions and inuseQueryon the client.
One picture
All three kinds of function are ordinary TypeScript files in a convex/ folder, deployed together.
Queries: read, cache, subscribe
export const list = query({ args: {}, handler: async (ctx) => { const owner = await currentActor(ctx); return await ctx.db .query("accounts") .withIndex("by_owner", (q) => q.eq("owner", owner)) .take(50); },});On the client this is one line: useQuery(api.accounts.list). The component re-renders whenever anything the query read changes. Queries are deterministic, so Convex caches the result and shares it between clients, and all reads inside one query happen at a single logical point in time.
That last part is the one I had not seen elsewhere. All the subscriptions a client holds move forward to the same database snapshot together. You never render one panel from before a write and the panel next to it from after.
Mutations are transactions
This is the feature I liked most, and the one the demo was built around. Two tabs, two accounts, a transfer button.
export const transfer = mutation({ args: { from: v.id("accounts"), to: v.id("accounts"), amount: v.number() }, handler: async (ctx, { from, to, amount }) => { const source = await ctx.db.get(from); const target = await ctx.db.get(to); if (!source || !target) throw new ConvexError("Unknown account"); if (source.balance < amount) throw new ConvexError("Insufficient funds"); await ctx.db.patch(from, { balance: source.balance - amount }); await ctx.db.patch(to, { balance: target.balance + amount }); await ctx.db.insert("transfers", { from, to, amount, requestedBy: source.owner }); },});There is no BEGIN and no COMMIT. The whole handler is one serializable transaction. If it throws, nothing is written. If two clients race on the same account, Convex notices the conflict and runs one of them again.1 The docs put it in one line: write your mutation functions as if they will always succeed.
In the demo, both tabs update the moment either one clicks. No refetch, no cache invalidation, no socket code in the app.
Actions: the door to the outside world
Mutations cannot call fetch, because a transaction that can be retried must not have side effects outside the database. Anything that talks to a vendor goes into an action. Actions are not transactional and are not retried for you, so I keep them thin: call the vendor, hand the result to a mutation.
The pattern I showed was recording and transcribing a meeting. The public mutation records the intent and schedules the work:
export const requestTranscript = mutation({ args: { meetingUrl: v.string() }, handler: async (ctx, { meetingUrl }) => { const owner = await currentActor(ctx); const meetingId = await ctx.db.insert("meetings", { owner, meetingUrl, status: "requested", }); await ctx.scheduler.runAfter(0, internal.meetings.transcribe, { meetingId }); return meetingId; },});Scheduling from a mutation is part of the transaction. If the insert rolls back, the action never runs. If the insert commits, the action is guaranteed to be scheduled. That removes a whole class of “row exists but the job was never queued” bugs that an outbox table usually exists to solve.
The action does the slow part and reports back through an internal mutation:
export const transcribe = internalAction({ args: { meetingId: v.id("meetings") }, handler: async (ctx, { meetingId }) => { await ctx.runMutation(internal.meetings.setStatus, { meetingId, status: "recording" }); // ...fetch the vendor here... await ctx.runMutation(internal.meetings.setStatus, { meetingId, status: "done" }); },});The UI watching meetings.list moves from requested to recording to done on its own. API keys live in the deployment’s environment variables and never reach the client or the repository.
Public and internal functions
query, mutation and action are public: any client that knows the deployment URL can call them. So each one validates its arguments and checks ctx.auth at the top. Identity comes from the verified token on the connection, never from an argument.
const identity = await ctx.auth.getUserIdentity();if (!identity) throw new ConvexError("Unauthenticated");internalQuery, internalMutation and internalAction can only be called from other functions, the scheduler, crons, HTTP routes and the dashboard. They have no public surface at all. My rule is simple: if a user should not trigger it directly, it is internal. setStatus above is internal, and so is the hourly cron that expires stale recordings.
Webhooks still need idempotency
Convex accepts webhooks through HTTP actions on a .convex.site URL. I verify the signature on the raw body before parsing anything, then pass the event to an internal mutation.
The platform does not change one thing: the vendor will deliver the same event more than once, and the handler must not care. The transactions make it easy to write the check and the state change together, but the check is still mine to write. I covered the shape I use in Idempotency is a contract, not a flag.
Paying for use, not for a box
The billing model is a bigger change than the API. With Supabase you pay for a Postgres instance. It costs the same under load and at night, the free tier keeps two active projects, and upgrading the organisation to Pro makes every project in it a paid one.
With Convex you pay for what runs: function calls, compute, storage, database I/O and egress. The free tier covers up to forty deployments, and projects without traffic cost nothing and are never paused. Going past the free limits moves you to pay-as-you-go, not straight to Pro. Pro is $25 per developer per month and is only needed to give other developers access.2
The line to watch is file egress. If a product serves a lot of files, put them behind R2 or a CDN, for which there is a component.
What you have to accept
- It is a document database, not SQL. Joins are ordinary code in a query. Analytics means an export or the
aggregatecomponent. - Limits apply per transaction, not per instance. A transaction may scan up to 32,000 documents, write up to 16,000 and read up to 16 MiB. A document is at most 1 MiB. Actions run for up to 30 minutes, or 10 in the Node runtime.
- Lock-in is real but bounded. The backend is open source under FSL-1.1, which turns into Apache-2.0 after two years, and it can be self-hosted on SQLite or Postgres. That is an exit, not an equal alternative to the cloud.
Before choosing it, I would check two things: how much a single transaction needs to read, and how much of the product depends on SQL-shaped reporting. If both answers are small, Convex removes more code than anything else I have tried this year.
Notes
-
This is optimistic concurrency control. The mutation runs, Convex checks at commit time whether anything it read has changed, and if so it throws the result away and runs again. It is also why mutations must not call the outside world: they may run more than once.
-
Prices and limits as checked on convex.dev and supabase.com on 3 September 2026. They change, so check them again before you decide.