Overview
The@shipdit/convex component keeps the last valid shipd snapshot in Convex. Your queries read
that local copy, so flag evaluation stays reactive and does not add a network request to each
function call. The integration is available on every shipd plan.
Mount one named component instance per shipd environment. For example, mount
shipdDevelopment and shipdProduction separately. Each instance has its own SDK key, signing
secret, snapshot, and health status.
Install
convex/convex.config.ts. The httpPrefix gives each instance a distinct
webhook route.
convex/convex.config.ts
npx convex dev after changing component mounts so Convex regenerates components.
Configure environment values
Set these values for every mounted instance:
The component fetches snapshots from
https://edge.useshipd.com.
Do not expose the SDK key or webhook secret to browser code.
Create the webhook destination
- Open the project in the shipd dashboard and go to Settings → Integrations.
- Under Convex, choose the matching environment.
- Enter
https://<your-deployment>.convex.site/shipd/production/webhook. - Click Create destination.
- Copy the signing secret immediately and replace
SHIPD_PRODUCTION_WEBHOOK_SECRETin Convex. - Redeploy, then click Test delivery.
.convex.site and use HTTPS. shipd signs the exact request body
and sends only publication metadata. The component fetches the canonical snapshot from the edge;
the webhook never contains flags or credentials.
Wrap host queries
Create one wrapper for each mounted instance. Defaults are required and stay type-safe.convex/lib/shipd.ts
ctx.auth. Authorize in the host function
before calling the wrapper:
convex/checkout.ts
getNumber, getJson, and evaluate. Use evaluate when you need the
reason, matched rule, snapshot version, or stale state.
Inspect sync health
CallgetStatus from an authorized host query:
hasSnapshot tells you whether an initial sync succeeded. version, etag, and fetchedAt
identify the cached snapshot. lastAttemptAt, lastError, and lastErrorAt describe sync health.
stale: true means a valid cached snapshot exists but the latest refresh failed.
Webhooks provide fast invalidation. A one-minute ETag poll is the reliability fallback. You can
also call syncNow from an authorized host action.
Understand defaults and stale snapshots
- Before the first valid snapshot, the wrapper returns your typed default.
- A missing flag or value-type mismatch also returns its typed default.
- After a successful sync, the component keeps the last valid snapshot indefinitely.
- A refresh failure marks that snapshot stale but does not replace it with defaults.
- Older out-of-order snapshots are ignored.
Rotate credentials
Rotate the webhook secret without creating a second destination:- In the project’s Settings → Integrations, choose the environment, then click Rotate secret.
- Copy the new secret immediately.
- Update the matching
SHIPD_WEBHOOK_SECRETvalue in Convex and redeploy. - Click Test delivery.
SHIPD_SDK_KEY, confirming a successful sync, and then revoking the old key.