convex-helpers npm package

Have you thought of turning convex-helpers into an npm package? https://github.com/get-convex/convex-helpers/tree/main
2 Replies
ian
ian2y ago
We're interested for sure - and we've done it for https://www.npmjs.com/package/@convex-dev/convex-lucia-auth. There's a few factors that make it a little tricky to do broadly: - Many helpers involve adding tables to your schema, and these are tables you'll want to customize. E.g. you'd want to pick the schema of your sessions table. - The end-to-end types often involve importing api or data model types from the generated files (convex/_generated/*). E.g. TableNames or Doc<TableName> are types that lean on the generated api. Some helpers are tough to parametrize ergonomically, so it's easier to copy the file and change the relative import for now. - Relatedly - a library can't register an endpoint / function, in cases where it needs an action to call a mutation, or to register a cron to fire a mutation. - Convex doesn't (yet) have name-spaced tables that modules can register, but it's something we keep thinking about.
ian
ian2y ago
As we get more conviction in which helpers feel "canonical" we want to publish open-source libraries for them. There's a few patterns that can help here. E.g. the RLS helper lets you create the type-parametrized wrapper functions in one place from the library, then import those function for your code. The lucia auth library has a function where you specify your custom fields for a table to a library, then get the table definition back that you add to your schema. A bit of boilerplate, but not too bad, and pretty explicit about what's happening.

Did you find this page helpful?