Skip to content

Video upload options for Sanity documents

1replyLast updated: Nov 13, 2026

What options do I have for adding video uploads to my document?
AI Update

There are four main ways to add video to a document:

1. A file field (store the file as-is)

Use this when you only need to store the video file and link to it, with no transcoding or adaptive streaming. The file type takes an accept option that limits which MIME types editors can upload:

import {defineField} from 'sanity'

defineField({
  name: 'videoFile',
  title: 'Video file',
  type: 'file',
  options: {
    accept: 'video/*',
  },
})

To get the URL, query videoFile.asset->url. To make the browser download the file, append ?dl= to the URL. You get the original file only: no streaming renditions and no thumbnails.

2. The Mux input plugin (streaming, transcoding, captions)

sanity-plugin-mux-input lets editors upload videos to Mux from inside Studio. Mux handles adaptive streaming, 4K, auto-generated captions, static MP4 renditions and analytics (overview). Mux is a separate service and bills separately.

Uploaded assets are stored as mux.videoAsset documents that include a playbackId. You can build a stream URL from it in GROQ, for example "https://stream.mux.com/" + playbackId.

3. Media Library video (Enterprise add-on)

If your organization uses Media Library, its video add-on processes uploads for streaming through Mux and delivers them from Sanity's CDN. This is a paid feature on certain Enterprise plans, and it's off by default. It requires Media Library to be enabled, the video add-on to be turned on, and Studio v4.0.1 or later (Working with video).

import {defineType} from 'sanity'
import {defineVideoField} from 'sanity/media-library'

export default defineType({
  name: 'videoDocument',
  title: 'Video Document',
  type: 'document',
  fields: [
    defineVideoField({title: 'Featured Video', name: 'video'}),
  ],
})

On the front end, call client.mediaLibrary.video.getPlaybackInfo(document.video.asset) to get the stream, thumbnail, renditions and subtitles. This needs @sanity/client 7.14.0+ configured with resource: {type: 'media-library', id: ...} and apiVersion: '2025-03-25' or later. Then play the video with @mux/mux-player-react, using customDomain="m.sanity-cdn.com". Private videos are supported through signed URLs. The guide linked above covers all of this.

4. Videos hosted elsewhere (YouTube, Vimeo, etc.)

If the videos already live on another platform, store a URL in a field and render the embed on your front end. For Portable Text, see How to add custom YouTube blocks to Portable Text.

Which to choose: use file for simple downloads or short clips. For real streaming, use the Mux plugin, or Media Library video if you're on an Enterprise plan that includes it. For videos you already host elsewhere, use embeds.

Show original thread
1 reply

Was this answer helpful?

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Related contributions