npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@oversightstudio/mux-video

v1.2.0

Published

Brings Mux Video to PayloadCMS.

Downloads

18,489

Readme

Mux Video Payload Plugin

Install

pnpm add @oversightstudio/mux-video @mux/mux-player-react

About

This plugin brings Mux Video to Payload! It creates a “Videos” collection within the admin panel, making it simple to upload videos directly to Mux and manage them.

Features include:

  • Support for both public and signed playback policies.
  • Ensures that videos deleted in the admin panel are automatically deleted from Mux, and vice versa.
  • Video gif previews on the videos collection list view, which can be disabled if required.

muxVideoPreview

Payload Setup

There are two possible setups for this plugin: The public setup, and the signed URLs setup. The main difference between the two is that the signed URLs setup requires setting up a little extra configuration, but that's about it.

To get started, you’ll need to generate your MUX tokens and secrets from the MUX Dashboard. When configuring the webhook, set the URL to the automatically generated API endpoint provided by this plugin at /api/mux/webhook. If you have set a custom API route in Payload config via routes.api, the API endpoint will be <your_custom_api_route>/mux/webhook.

Public Setup

import { buildConfig } from 'payload'
import { muxVideoPlugin } from '@oversightstudio/mux-video'

export default buildConfig({
  plugins: [
    muxVideoPlugin({
      enabled: true,
      initSettings: {
        tokenId: process.env.MUX_TOKEN_ID || '',
        tokenSecret: process.env.MUX_TOKEN_SECRET || '',
        webhookSecret: process.env.MUX_WEBHOOK_SIGNING_SECRET || '',
      },
      uploadSettings: {
        cors_origin: process.env.NEXT_PUBLIC_SERVER_URL || 'http://localhost:3000',
      },
    }),
  ],
})

Signed URLs Setup

import { buildConfig } from 'payload'
import { muxVideoPlugin } from '@oversightstudio/mux-video'

export default buildConfig({
  plugins: [
    muxVideoPlugin({
      enabled: true,
      initSettings: {
        tokenId: process.env.MUX_TOKEN_ID || '',
        tokenSecret: process.env.MUX_TOKEN_SECRET || '',
        webhookSecret: process.env.MUX_WEBHOOK_SIGNING_SECRET || '',
        jwtSigningKey: process.env.MUX_JWT_KEY_ID || '',
        jwtPrivateKey: process.env.MUX_JWT_KEY || '',
      },
      uploadSettings: {
        cors_origin: process.env.NEXT_PUBLIC_SERVER_URL || 'http://localhost:3000',
        new_asset_settings: {
          playback_policy: ['signed'],
        },
      },
    }),
  ],
})

Options

| Option | Type | Default | Description | |---------------------------|--------------------------------------------------|----------|---------------------------------------------------------------------------------------------------------| | enabled | boolean | Required | Whether the plugin is enabled. | | initSettings | MuxVideoInitSettings | Required | Initialization settings for the Mux implementation. | | uploadSettings | MuxVideoUploadSettings | Required | Upload settings for Mux video assets. | | extendCollection | string | Optional | The slug of an existing collection to extend with Mux video functionality. | | access | (request: PayloadRequest) => Promise<boolean> \| boolean | Optional | An optional function to determine who can upload files. Should return a boolean or a Promise resolving to a boolean. | | signedUrlOptions | MuxVideoSignedUrlOptions | Optional | Options for signed URL generation. | | adminThumbnail | 'gif' \| 'image' \| 'none' | "gif" | Specifies the type of thumbnail to display for videos in the collection list view. |

initSettings Options

| Option | Type | Default | Description | |-----------------------|-------------|----------|-----------------------------------------------------------| | tokenId | string | Required | The Mux token ID. | | tokenSecret | string | Required | The Mux token secret. | | webhookSecret | string | Required | The secret used to validate Mux webhooks. | | jwtSigningKey | string | Optional | Optional JWT signing key, required for signed URL setup. | | jwtPrivateKey | string | Optional | Optional JWT private key, required for signed URL setup. |

uploadSettings Options

| Option | Type | Default | Description | |---------------------------|-----------------------|----------|--------------------------------------------------------| | cors_origin | string | Required | The required CORS origin for Mux. | | new_asset_settings | MuxVideoNewAssetSettings | Optional | Additional settings for creating assets in Mux. |

new_asset_settings Options

| Option | Type | Default | Description | |-------------------------------|-----------------------------|----------|-------------------------------------------------------------| | playback_policy | Array<'public' | 'signed'> | public | Controls the playback policy for uploaded videos. Default is public. |

signedUrlOptions Options

| Option | Type | Default | Description | |-------------------------------|-------------|----------|-------------------------------------------------------------| | expiration | string | "1d" | Expiration time for signed URLs. Default is "1d". |

Videos Collection

This is the collection generated by the plugin with the mux-video slug.

| Field | Type | Read-Only | Description | |-------------------|-----------|-----------|-------------| | title | text | No | A unique title for this video that will help you identify it later. | | assetId | text | Yes | | | duration | number | Yes | | | posterTimestamp| number | No | A timestamp (in seconds) from the video to be used as the poster image. When unset, defaults to the middle of the video. | | aspectRatio | text | Yes | | | maxWidth | number | Yes | | | maxHeight | number | Yes | | | playbackOptions| array | Yes | |

playbackOptions Fields

| Field | Type | Read-Only | Description | |---------------|---------|-----------|-------------| | playbackId | text | Yes | | | playbackPolicy | select | Yes | Options: signed, public | | playbackUrl | text (virtual) | Yes | | | posterUrl | text (virtual) | Yes | |

Payload Usage Example

import { CollectionConfig } from 'payload'

export const ExampleCollection: CollectionConfig = {
  slug: 'example',
  fields: [
    // To link videos to other collection, use the `relationship` field type
    {
      name: 'video',
      label: 'Preview Video',
      type: 'relationship',
      relationTo: 'mux-video',
    },
  ],
}

Frontend Usage Example

import config from '@/payload.config'
import { getPayload } from 'payload'
import MuxPlayer from '@mux/mux-player-react'

async function Page() {
  const payload = await getPayload({ config })

  const video = await payload.findByID({
    collection: 'mux-video',
    id: 'example',
  })

  return (
    <MuxPlayer
      // Using playback id
      playbackId={video.playbackOptions![0].playbackId!}
      // Or use the playback URL
      src={video.playbackOptions![0].playbackUrl!}
      // Poster
      poster={video.playbackOptions![0].posterUrl!}
    />
  )
}

export default Page

Credits

  • Huge shoutout to jamesvclements for building the initial version of this plugin!
  • Shoutout to Paul for being a real one.