Skip to content

What are the best practices for hosting videos on Vercel?

When building your Next.js site on Vercel, you might want to add video assets. Videos can be an important part of your design or content marketing. However, large video files can often lead to excessive bandwidth usage.

For example, you might want a background image as the header on your marketing site.

<video width="320" height="240" loop autoPlay>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
  Your browser does not support the video tag.

An example auto-playing Video HTML element.

Video Hosting Solutions

We recommend hosting video assets (like .mp4 and .gif files) on dedicated content platforms like:

Moving these assets to a third-party solution will help reduce your usage on Vercel, as well as potentially unlocking additional options to customize, compress, and transform your video files.

It's important to ensure your videos are compressed and optimized regardless of the platform they're being hosted on.

What About Images?

Vercel has built-in Image Optimization, which works with zero-configuration using the Next.js Image Component. We recommend using these solutions for optimal Core Web Vitals and performance.

For example, here's a background image using next/image (Demo):

import Image from 'next/image'
import ViewSource from '../components/view-source'
import { bgWrap, bgText } from '../styles.module.css'

const Background = () => (
    <ViewSource pathname="pages/background.js" />
    <div className={bgWrap}>
    <p className={bgText}>
      Image Component
      <br />
      as a Background

export default Background

An example background image using the Next.js Image component.

Couldn't find the guide you need?