Overview
A complete Convex backend that mounts the@shipdit/convex component and evaluates new-checkout and search-variant in an authenticated query. The component stores the snapshot in Convex, so evaluations are reactive and add no network call.
What’s in it
convex/convex.config.tsmounts one component instance namedshipdfor one shipd environment.convex/lib/shipd.tswraps the instance with typed defaults.convex/storefront.tsauthorizes the caller, then evaluates both flags for that user.- A signed webhook from shipd triggers a refresh when a snapshot is published. A one-minute poll is the fallback.
convex/_generated/ is created by npx convex dev.
Files
package.json
shipdit is a dev dependency here because only shipd.config.ts imports it. Convex functions use @shipdit/convex.
shipd.config.ts
convex/convex.config.ts
convex/http.ts
readonly tuple. Keep it in sync with shipd.config.ts.
convex/lib/shipd.ts
convex/storefront.ts
Run it
1
Push the flags
2
Start Convex
components.shipd. Leave it running.3
Set environment values
In a second terminal, use a server SDK key for the environment you pushed to. Set a placeholder secret for now.
4
Create the webhook destination
In the shipd dashboard, open the project’s Settings → Integrations. Under Convex, choose the environment and enter Click Test delivery.
https://<your-deployment>.convex.site/shipd/webhook. Click Create destination, copy the signing secret, and replace the placeholder:5
Call the query
new-checkout in the dashboard and click Save environment. The webhook refreshes the component and subscribed clients re-render with the new value.
Adapt it
- Mount one named instance per shipd environment (for example
shipdDevelopmentandshipdProduction), each with its own SDK key,httpPrefix, and webhook secret. - Add attributes to the context (
plan,organizationId) from your own tables after authorization. - Use
shipd.evaluate(ctx, key, context)to get the reason and snapshot version, andshipd.getStatus(ctx)to check sync health. - Call
shipd.syncNow(ctx)from an authorized action to force a refresh.