Bright ideas and techniques for building with Convex.

Patterns

Queries that scale
As your app grows from tens to hundreds to thousands of users, there are some techniques that will keep your database queries snappy and efficient. I’ve put together a short list of the most common techniques used by teams scaling on Convex.
Ian Macartney's Profile image
Ian Macartney
a month ago
Observing your app in production
By setting up dedicated tools, you can get actionable data to help understanding errors, performance, user behavior and allow you respond quickly when things change.
Ian Macartney's Profile image
Ian Macartney
7 days ago
YOLO: Get to an MVP fast
Before you burden yourself with “best practices” for large-scale companies, focus on what will reduce your feedback cycles and help you ship early and often. Think about your use case, not your toolbox.
Ian Macartney's Profile image
Ian Macartney
8 days ago
Using TypeScript to Write Complex Query Filters
There’s a new Convex helper to perform generic TypeScript filters, with the same performance as built-in Convex filters, and unlimited potential.
Lee Danilek's Profile image
Lee Danilek
15 days ago
Automatically Retry Actions
Learn how to automatically retry actions in Convex while also learning a little about scheduling, system tables, and function references.
James Cowling's Profile image
James Cowling
a month ago
Supercharge `npm run dev` with package.json scripts
With a simple `npm run dev` we can sign up a user for Convex, add seed data, and run the frontend and backend (including database) in parallel. Here's how we do it, and how to undo it too.
Ian Macartney's Profile image
Ian Macartney
2 months ago
Convex Ents: Manage your document relationships
Convex Ents is a library that provides: simpler ways to model and query related documents, ability to easily map and filter documents, enforcing unique field values, default field values, cascading deletes, soft deletion and more!
Michal Srb's Profile image
Michal Srb
2 months ago
Track Sessions Without Cookies
Advice and resources for session tracking per-tab or per-browser via localStorage / sessionStorage using React Context, hooks, and some utilities to make your life easier.
Ian Macartney's Profile image
Ian Macartney
2 months ago
Using branded types in validators
If you have a more specific type than what you can express with Convex validators, you can still document that at the type level in Convex by casting once in your schema definition.
Ian Macartney's Profile image
Ian Macartney
2 months ago
Database Relationship Helpers
Traverse database relationships in a readable, predictable, and debuggable way. Support for one-to-one, one-to-many, and many-to-many via utility functions available in convex-helpers.
Ian Macartney's Profile image
Ian Macartney
2 months ago
Argument Validation without Repetition
In the first post in this series, the Types and Validators cookbook,, we shared several basic patterns & best practices for reusing types & validators from your schema. In this post, we introduce a few more advanced techniques & helpers to further reduce duplication and accelerate your Convex workflow.
Anjana Vakil's Profile image
Anjana Vakil
3 months ago
4 Devs, 1 Idea, 4 Apps in 4 Hours(!!) with Convex
Using Convex, 4 web devs built their own fullstack app based on this prompt: > Build a way to show real-time updates on the website for a Dungeons and Dragons-themed small business! See what they built, learn how they did it, and watch their reactions to each other's work in this installment of the "4 Web Devs, 1 App Idea" video series.
Jason Lengstorf's Profile image
Jason Lengstorf
3 months ago
Zod with TypeScript for Server-side Validation and End-to-End Types
Use Zod with TypeScript for argument validation on your server functions allows you to both protect against invalid data, and define TypeScript types that propagate to your client. This can now be used as an alternative to the built-in argument validation on Convex.
Ian Macartney's Profile image
Ian Macartney
3 months ago
Customizing serverless functions without middleware
Re-use code and centralize request handler definitions with discoverability and type safety and without the indirection of middleware or nesting of wrappers. Use the new customFunction module in convex-helpers for your Convex TypeScript functions.
Ian Macartney's Profile image
Ian Macartney
3 months ago
Types and Validators in TypeScript: A Convex Cookbook
It can be tough to wrangle types to behave how you want them to. Thankfully, Convex was designed to make the experience with types perfect. Learn why that's the case here.
Anjana Vakil's Profile image
Anjana Vakil
4 months ago
Seeding Data for Preview Deployments
Now that we've launched Preview Deployments on Convex, you can test out backend changes easier than ever. But you may want to seed your project with data first, so let's go over how to do that.
Ian Macartney's Profile image
Ian Macartney
5 months ago
GPT Streaming With Persistent Reactivity
Stream GPT responses without brittle browser-based HTTP streaming. Multiplayer reactivity, persistence, reactivity via Convex. Using OpenAI’s Node SDK server-side, and Convex's useQuery hook client-side.
Ian Macartney's Profile image
Ian Macartney
5 months ago
Testing Your App: How to Generate Fake Data
Learn how to generate fake data for your dev deployments using the Faker library
Nicolas Ettlin's Profile image
Nicolas Ettlin
9 months ago
Using Pinecone and Embeddings
Pinecone and Convex are a good match when you're looking to build an application that leverages embeddings and also has application data.
Ian Macartney's Profile image
Ian Macartney
9 months ago
The Magic of Embeddings
Embeddings, why they’re useful, and how we can store and use them in Convex.
Ian Macartney's Profile image
Ian Macartney
10 months ago
Row Level Security: Wrappers as "Middleware"
Implementing row-level security on Convex as a library. Wrap access to the database with access checks written in plain old JS / TS.
Lee Danilek's Profile image
Lee Danilek
10 months ago
Migrating Data With Mutations
Using mutations to migrate data in Convex.
Ian Macartney's Profile image
Ian Macartney
a year ago
Searching for Sanity
Your document is safely stored, but search is coming up empty? Inconsistent search systems can really confuse users! Don't worry–in Convex, transactional search indexing ensures that users always get what they expect and your apps just work.
Jamie Turner's Profile image
Jamie Turner
a year ago
Advanced HTTP Endpoints: Convex ❤️ Hono
Adding advanced HTTP Endpoint functionality by extending Convex with Hono.
Sarah Shader's Profile image
Sarah Shader
a year ago
Help, my app is overreacting!
Reactive backends like Convex make building live-updating apps a cinch, but default behavior might be too reactive for some use cases. Not to worry! Let’s fine-tune the reactive dataflow of a Convex + React app to deliver a better UX.
Anjana Vakil's Profile image
Anjana Vakil
a year ago
Background Job Management
Implement asynchronous job patterns using a table to track progress. Fire-and-forget, cancelation, timeouts, and more.
Ian Macartney's Profile image
Ian Macartney
a year ago
Anonymous Users via Sessions
Getting users to sign up for a new service before seeing any benefits is challenging. In this post, we looked at a couple of strategies for managing user information without requiring a login.
Ian Macartney's Profile image
Ian Macartney
a year ago
Sessions: Wrappers as "Middleware"
How to implement session storage with Convex, using some helper functions we wrote. While most of your data is associated with a user or another document, sometimes you have data that is specific to a user’s browser tab, or associated with a user who isn’t logged in. Some of this data is stored on the client, such as in the browser’s `sessionStorage` or `localStorage`, while other data is stored on the server.
Ian Macartney's Profile image
Ian Macartney
a year ago
Zod Validation: Wrappers as “Middleware”
Function validation is important for a production app because you can’t always control which clients are talking to your server. See how to use zod to validate your Convex functions, using our withZod wrapper.
Ian Macartney's Profile image
Ian Macartney
a year ago
Edge to Butt: Wrappers as "Middleware"
Convex middleware serves many purposes. Sometimes authentication, sometimes i18n. This time? Making sense (or nonsense) of emerging technology industry trends.
Jamie Turner's Profile image
Jamie Turner
a year ago
Authentication: Wrappers as “Middleware”
Using wrapper functions like withUser can help you organize your code into middleware-like blocks that you can compose to keep your function logic concise.
Ian Macartney's Profile image
Ian Macartney
a year ago
Implementing Presence with Convex
Some patterns for incorporating presence into a web app leveraging Convex, and sharing some tips & utilities I built along the way.
Ian Macartney's Profile image
Ian Macartney
a year ago
Throttling Requests by Single-Flighting
For write-heavy applications, use single flighting to dynamically throttle requests. See how we implement this with React hooks for Convex.
Ian Macartney's Profile image
Ian Macartney
a year ago
Launching Features Right on Time: Feature Gating
Today we’re going to talk about how to flip features on and off remotely using a clever use of the reactive nature of Convex queries.
Ian Macartney's Profile image
Ian Macartney
a year ago
Managing Reactivity with useBufferedState
Reactivity has taken a dominant position today within web app development. Our components and app state are all reactive, and the world has adapted–most would argue, for the better. But has Convex gone too far? 😉 A new generation of serverless backends like Convex is recklessly spreading reactivity across our databases, server-side functions, and protocols, making global reactivity a new phenomenon. Shared global data is becoming reactive by default. Is this good for the world? In this video, Jamie Turner explores one circumstance where this pervasive reactivity poses a challenge, and he builds one useful abstraction for taming over-reactivity and turning it back into a strength.
Jamie Turner's Profile image
Jamie Turner
2 years ago