Sam
Sam•3w ago

🔨 Convex Component Template – Production-Ready Boilerplate

Just released a production-ready template for building Convex components. If you want to build reusable Convex components (like rate limiters, sharded counters, document search, etc.) and publish them to npm, this template has everything you need: - Automated rename script – transforms the entire codebase to your component name - Live reloading with --live-component-sources - Testing setup with convex-test (auto-discovery included) - Changesets for versioning + automated npm publishing - pkg.pr.new for preview packages on every commit - Example app showing how to use your component - Pre-configured CI/CD with GitHub Actions Just clone it, run bun rename.ts, and start building. Repo: https://github.com/samhoque/convex-component-template
21 Replies
Sam
SamOP•3w ago
If you prefer to use Zodvex instead, there is now a branch that defaults to using zodvex for functions & schema. https://github.com/SamHoque/convex-component-template/tree/zodvex
GitHub
GitHub - SamHoque/convex-component-template at zodvex
A modern Convex component boilerplate with Bun, Biome, TypeScript, and automated testing. - GitHub - SamHoque/convex-component-template at zodvex
ibrahimyaacob
ibrahimyaacob•2w ago
@Sam what if i want to use the component pattern, but just on my current project, any guideline for this?
Sam
SamOP•2w ago
Hey Ibrahim, what do you mean? I set the structure to how I like, however feel free to change it to your likings.
ibrahimyaacob
ibrahimyaacob•2w ago
I just want to build a component without actually creating the npm package How do i do that?
Sam
SamOP•2w ago
You could move everything into a directory called components and see how the example directory works in my template. and rather than getting the component sources from src get it from your components directory.
ibrahimyaacob
ibrahimyaacob•2w ago
i just looked into your codebase and i see the defineComponent api that i didnt know even exist there should be a dedicated section in convex doc for building custom compoennt cc @erquhart
Sam
SamOP•2w ago
GitHub
GitHub - get-convex/sharded-counter at 927521a83b4297858bb83926fdc1...
Contribute to get-convex/sharded-counter development by creating an account on GitHub.
ibrahimyaacob
ibrahimyaacob•2w ago
oh man i've been missing out these
Sam
SamOP•2w ago
If you break it down, components are very easy to make, all you need to make sure is you got a convex.config.ts with the defineComponent and your component directory exports the query/mutation/action as well as the _generated directory. :xzibit:
ibrahimyaacob
ibrahimyaacob•2w ago
yeah looking at the doc it should be funny that last week i asked #ask-ai
ibrahimyaacob
ibrahimyaacob•2w ago
No description
Sam
SamOP•2w ago
Feel free to ask any questions, or if you need help, I am always available.
erquhart
erquhart•2w ago
Not a public api yet (cc @Sam 😅) - things can still change or break.
ibrahimyaacob
ibrahimyaacob•2w ago
will do thanks any eta of when i can expect this, im looking forward to refactor a whole lots of things in my messy codebase haha
erquhart
erquhart•2w ago
Soon, working on bringing component authoring api's out of beta
Sam
SamOP•2w ago
Understandable, however it seems stable for now. Yep! that's what I am doing now, I am making everything into a component and providing api/react hooks to my SaaS.
Sam
SamOP•2w ago
:xzibit: via npm package
No description
raideno
raideno•2w ago
This is really helpfull thank you, will convert some libraries to component
ibrahimyaacob
ibrahimyaacob•2w ago
yeah i think this componentazation of convex code should be a priority, convex bloated codebase sucks
Clever Tagline
Clever Tagline•2w ago
To follow up on what @erquhart said above, James mentioned in the AMA today that the official component authoring API should be released soon, possibly as soon as next week.

Did you find this page helpful?