Skip to main content

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.ts mounts one component instance named shipd for one shipd environment.
  • convex/lib/shipd.ts wraps the instance with typed defaults.
  • convex/storefront.ts authorizes 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
The wrapper takes a flag map with variants as a 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

This creates the deployment and generates 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 https://<your-deployment>.convex.site/shipd/webhook. Click Create destination, copy the signing secret, and replace the placeholder:
Click Test delivery.
5

Call the query

Add a rule to 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 shipdDevelopment and shipdProduction), 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, and shipd.getStatus(ctx) to check sync health.
  • Call shipd.syncNow(ctx) from an authorized action to force a refresh.

Next