Components are here! https://www.convex.dev/components
And now you can build new ones yourself.
npm create convex@latest -- --component
This will generate a new template component, with an example app.
Check out the template’s README for details about the contents and how to make the component your own.
All first-party components are open source, so you can check out their source code to see example patterns.
Examples:
A component has functions, tables, file storage, and scheduled functions. A component gets plugged into a Convex app (or into a parent component), which can then access it through its public interface.
src/component/ is the component
convex/ directory would look in a Convex app. Importantly it’s not in the convex/ directory.schema.ts. These tables are only accessible from within the component._generated directory for auto-generated types, specific to the component’s API and data model.src/client/ contains a class that runs in the app (or parent component)
new Counter(components.counter), and defines functions that take in arguments like ctx: RunQueryCtxctx.runQuery(this.component.public.count)ctx.runQuery(components.counter.public.count) directly. The client library is useful for hiding implementation details and implicit dependencies (see below).src/react/ can hold React components (no pun intended) for interacting with the Convex component.
example/ is an example Convex app for testing the component
In the Convex dashboard, you can select each component to see data, functions, file storage, logs, etc. for each component.
