Getting started
Install and mount the component.
Install the stable package:
npm install @clipin/convex-credits convexFor local development, clone the repository and run bun install followed by bun run build.
The component package exports Credits and its Convex configuration.
import { defineApp } from "convex/server";
import credits from "@clipin/convex-credits/convex.config.js";
const app = defineApp();
app.use(credits);
export default app;After Convex code generation, create the client in your host app.
import { Credits } from "@clipin/convex-credits";
import { components } from "./_generated/api";
export const credits = new Credits(components.credits, "production");The namespace separates accounts and operation keys. Use a namespace controlled by your server.
Call mutations from a host mutation when you need job changes and credit changes to commit together. Never take a client-supplied price or account owner as authorization.