Mux
Video assets, uploads and webhook synchronization
git clone https://github.com/bijectionhq/mux.git
cd mux
git checkout cf453d509931cb1edc05b142ab7eac023bbc349bBijection repository access is required. Request access.
Description
Video assets, uploads and webhook synchronization
Explore the package README for API concepts, configuration, and examples. Check the Bijection source for adaptation-specific setup.
Review the source and its dependencies before adopting this package. Source availability does not establish npm publication or runtime qualification.
Getting started
- Get the source at the revision above and read its package documentation.
- Check the required Bijection SDK version, dependencies, and external service credentials.
- Follow the package setup instructions and the guide to using components.
- Exercise the component in your deployment according to your project’s verification rules.
Open source
Maintained source: bijectionhq/mux. Based on muxinc/mux-convex-component. License: Not specified. Consult the repository for license terms, notices, and contributor attribution.
From the upstream publisher
Convex Component for syncing Mux video data and app metadata.
Explore the demo ↗Upstream overview
From the upstream package documentation.
The Mux Convex component synchronizes video data from Mux's video platform into your Convex database, providing real-time updates through webhooks and backfill operations. It creates tables for assets, uploads, live streams, and events, along with mutations and query helpers for managing video catalogs. The component handles the complex integration between Mux's API and Convex's reactive database, keeping your app's video state automatically synchronized.
Use cases
From the upstream package documentation.
- Building a video-first application where you need real-time updates when video processing completes, thumbnails are generated, or live streams change status
- Creating a video content management system that requires querying video assets by metadata like user ownership, titles, tags, or custom fields
- Developing a video platform where multiple users upload content and you need to track upload progress, processing status, and asset availability in real-time
- Integrating Mux video into an existing Convex app without manually managing webhook endpoints, database schema, or API synchronization logic
- Building reactive video UIs that automatically update when video assets change state, eliminating the need for polling Mux's API
How it works
From the upstream package documentation.
The component provides Convex tables that mirror Mux's data model, including assets, uploads, liveStreams, and events, plus a videoMetadata table for app-specific data like user ownership and custom fields. It includes mutations to upsert and delete synced Mux objects, along with query helpers for retrieving video catalog data.
Integration happens through two mechanisms: a one-time backfill operation via migrations:backfillMux that syncs existing Mux data, and webhook handling through generated routes that process real-time updates. The companion CLI package @mux/convex-mux-init scaffolds the necessary app-level Convex files including webhook handlers, HTTP routes, and migration functions.
The component follows Convex's architecture pattern where the component itself contains only the schema and database functions, while Node.js runtime code (Mux SDK calls, webhook verification) lives in generated app-level files. This separation allows the component to work within Convex's execution model while still integrating with Mux's Node.js SDK and webhook system.
Upstream package FAQ
How does the @mux/convex component keep video data synchronized?
The @mux/convex component uses two synchronization methods: a one-time backfill migration to import existing Mux objects, and webhooks that update Convex tables in real-time as Mux video state changes. Both are required to prevent data drift over time.
What data does the component store from Mux?
The @mux/convex component creates Convex tables for Mux assets, uploads, liveStreams, and events. It also provides a videoMetadata table for app-level data like userId, title, visibility, tags, and custom fields alongside the synced Mux data.
Can I use a different component name when mounting?
Yes, the @mux/convex component supports custom names when mounting. If you use a different name like 'videoInfra', regenerate the app-level wrappers with npx @mux/convex init --component-name videoInfra --force to match your configuration.
Why does the component use app-level wrappers instead of calling component functions directly?
The @mux/convex component follows Convex best practices by separating component logic from Node runtime integration. The component handles schema and mutations, while app-level wrappers generated by the CLI handle Mux SDK calls, webhook verification, and backfill operations that require Node APIs.
Use with agents and CLI
Give your coding agent the component’s source identity and setup guidance.
Help me integrate Mux with Bijection.
Read: https://bijection.com/components/mux/SKILL.md
Check SDK compatibility and dependency availability.
Follow this project's execution and verification rules.Upstream README.md
View repository ↗Documentation from muxinc/mux-convex-component, recorded October 23, 2026. APIs and setup may differ in the Bijection adaptation.
Mux Convex Component
A reusable Convex component for apps that use Mux for video. Sync your Mux video data with Convex and build video apps with a real-time database backing your catalog.
This package gives you:
- Convex tables for Mux
assets,uploads,liveStreams, andevents - Mutations to upsert/delete synced Mux objects
- App-level
videoMetadatastorage (userId, title, visibility, tags, custom fields) - Query helpers for catalog and user-facing video data
- A separate companion CLI package,
@mux/convex-mux-init, to scaffold app-level Convex wrappers (npx convex-mux-init)
Quickstart
1) Install packages
npm i @mux/convex @mux/mux-node
npm i -D @mux/convex-mux-init
If you prefer not to install the scaffold CLI, you can run it directly with
npx:
npx @mux/convex-mux-init@latest --component-name mux
2) Generate app-level Convex files
npx convex-mux-init --component-name mux
# or without installing it
npx @mux/convex-mux-init@latest --component-name mux
This creates:
convex/convex.config.tsconvex/migrations.tsconvex/muxWebhook.tsconvex/muxHttp.tsconvex/http.tsif your app does not already have one
If files already exist, the CLI skips them unless you pass --force.
Existing convex/http.ts is never overwritten.
3) Set Mux API env vars in Convex
npx convex env set MUX_TOKEN_ID <your_mux_token_id>
npx convex env set MUX_TOKEN_SECRET <your_mux_token_secret>
4) Start Convex and run backfill
npx convex dev
npx convex run migrations:backfillMux '{}'
5) Register the webhook route
If npx convex-mux-init created convex/http.ts for you, this is already
done.
If your app already had convex/http.ts, wire the generated helper into your
existing router:
import { httpRouter } from "convex/server";
import { registerMuxHttpRoutes } from "./muxHttp";
const http = httpRouter();
registerMuxHttpRoutes(http);
export default http;
6) Configure Mux webhook endpoint
In the Mux dashboard, create a webhook endpoint:
- URL for deployed app:
https://<your-deployment>.convex.site/mux/webhook - URL for local development: use a tunnel (e.g. ngrok or cloudflared) to
/mux/webhook
Copy the webhook signing secret and set it in Convex:
npx convex env set MUX_WEBHOOK_SECRET <your_mux_webhook_secret>
7) Verify data in Convex dashboard
Tables to check:
assetsuploadsliveStreamseventsvideoMetadata
Why both backfill and webhook?
- Backfill is a one-time catch-up for existing Mux objects.
- Webhooks keep your Convex tables updated in near real time as Mux state changes.
Without webhooks, data will drift over time.
Runtime model
This follows Convex component best practices:
@mux/convexis component-only (schema, queries, mutations)- Node runtime integration (Mux SDK, webhook verification, backfill) lives in app-level code in your project
@mux/convex-mux-initis the separate CLI package that scaffolds those app-level files for you
Using a different component name
If you mount with a different name, for example:
app.use(mux, { name: "videoInfra" });
Then regenerate wrappers with the matching name:
npx convex-mux-init --component-name videoInfra --force
Common commands
# regenerate wrappers
npx convex-mux-init --component-name mux --force
# run backfill with options
npx convex run migrations:backfillMux '{"maxAssets":500,"defaultUserId":"dev-user-1","includeVideoMetadata":true}'
# run against prod deployment
npx convex run --prod migrations:backfillMux '{"maxAssets":500}'
Troubleshooting
Could not find function for 'migrations:backfillMux': Ensureconvex/migrations.tsexists and exportsbackfillMux, then runnpx convex dev.InvalidReference ... does not export [mux_node.backfillAssets]: Do not callcomponents.<name>.mux_node.*directly. Use the app-level wrappers generated bynpx convex-mux-init.- TypeScript
webhooks.unwrap ... Record<string, unknown>: Regenerate wrappers withnpx convex-mux-init --force. - TypeScript
request.headers.entries is not a function/property: Build headers withrequest.headers.forEach(...)inconvex/muxHttp.ts. - Webhooks route compiles but never updates tables: If
ingestMuxWebhookis generated asinternalAction, call it viainternal.muxWebhook.ingestMuxWebhook(notanyApi.*). Node APIs without "use node": Ensure Node runtime files start with"use node";.- Bundling fails on
node:fs/node:pathfrom@mux/convex/bin/*: Upgrade to the split packages and use@mux/convex-mux-initas the separate scaffold CLI.