VercelLogotypeVercelLogotype
LoginSign Up
Back to Templates

Next.js Video Starter

The fastest way to add video to your Next.js app with Mux.

DeployView Demo
Contentful thumbnail for next-video-starter

Table of Contents

  • Deploy: Need a Mux account? Start here.
  • Getting Started: Already created a Mux account using the Vercel integration? Start here.
  • Manual Setup: Interested in running locally and deploying manually? Start here.

Deploy

Vercel deployment will guide you through creating a Mux account and project with $20 of usage/month for $0.

Getting Started

This section assumes you've setup a Mux account and project using the Vercel Integration (press deploy button above). If you only want to develop locally, follow the Manual Setup steps below.

Step 1. Pull environment variables

You'll need your Mux access token and secret token before you can begin adding videos. Run the following command to pull them from Vercel:

vercel env pull

Step 2. Add your video

Add your video directly to the /videos directory. For example, /videos/my-video.mp4.

Step 3. Import your video

Import your video into the home page and replace the getting started video.

- import getStarted from "/videos/get-started.mp4";
+ import myVideo from "/videos/my-video.mp4";

Step 4. Add the video to the player

Finally, set the video src to point to your newly imported video.

- <Video className={styles.video} src={getStarted} />
+ <Video className={styles.video} src={myVideo} />

Step 5. Celebrate!

Run npm run dev! Congratulations, you're now streaming a video just like some of your favorite sites such as YouTube or Netflix! Interested in how video streaming works?

What now? See the next-video docs to learn how to set custom poster images, create background videos, use a custom player, and more!

Manual Setup

Step 1. Create your Mux account

Option 1: The easiest way to get started with Mux is through the native integration in the Vercel Marketplace. Vercel Marketplace users will get $20 of usage/month for $0. Learn more.

Option 2: You can also get started by creating an account directly in Mux.

Step 2. Clone this example

git clone git@github.com:muxinc/next-video-starter.git
cd next-video-starter
npm install

Step 3. Set up environment variables

Copy the .env.local.example file in this directory to .env.local (which will be ignored by Git):

cp .env.local.example .env.local

Then, go to the settings page in your Mux dashboard, get a new API Access Token. Use that token to set the variables in .env.local:

  • MUX_TOKEN_ID should be the TOKEN ID of your new token
  • MUX_TOKEN_SECRET should be TOKEN SECRET

Step 4. Add your own video

Go to the add your video step in the getting started section above to start playing your own videos.

Step 5. Deploy on Vercel

You can deploy this app to the cloud with Vercel (Documentation).

To deploy on Vercel, you need to set the MUX_TOKEN_ID and MUX_TOKEN_SECRET environment variables using either the Vercel Dashboard or the Vercel CLI

Then push the project to GitHub/GitLab/Bitbucket and import to Vercel to deploy.

GitHub Repomuxinc/next-video-starter
Use Cases
Starter
Stack
Next.jsCSS Modules
CMS
Mux

Related Templates

Get Started

  • Templates
  • Supported frameworks
  • Marketplace
  • Domains

Build

  • Next.js on Vercel
  • Turborepo
  • v0

Scale

  • Content delivery network
  • Fluid compute
  • CI/CD
  • Observability
  • AI GatewayNew
  • Vercel AgentNew

Secure

  • Platform security
  • Web Application Firewall
  • Bot management
  • BotID
  • SandboxNew

Resources

  • Pricing
  • Customers
  • Enterprise
  • Articles
  • Startups
  • Solution partners

Learn

  • Docs
  • Blog
  • Changelog
  • Knowledge Base
  • Academy
  • Community

Frameworks

  • Next.js
  • Nuxt
  • Svelte
  • Nitro
  • Turbo

SDKs

  • AI SDK
  • Workflow SDKNew
  • Flags SDK
  • Chat SDK
  • Streamdown AINew

Use Cases

  • Composable commerce
  • Multi-tenant platforms
  • Web apps
  • Marketing sites
  • Platform engineers
  • Design engineers

Company

  • About
  • Careers
  • Help
  • Press
  • Legal
  • Privacy Policy

Community

  • Open source program
  • Events
  • Shipped on Vercel
  • GitHub
  • LinkedIn
  • X
  • YouTube

Loading status…

Select a display theme:
    • AI Cloud
      • v0

        Build applications with AI

      • AI SDK

        The AI Toolkit for TypeScript

      • AI Gateway

        One endpoint, all your models

      • Vercel Agent

        An agent that knows your stack

      • Sandbox

        AI workflows in live environments

    • Core Platform
      • CI/CD

        Helping teams ship 6× faster

      • Content Delivery

        Fast, scalable, and reliable

      • Fluid Compute

        Servers, in serverless form

      • Observability

        Trace every step

    • Security
      • Bot Management

        Scalable bot protection

      • BotID

        Invisible CAPTCHA

      • Platform Security

        DDoS Protection, Firewall

      • Web Application Firewall

        Granular, custom protection

    • Company
      • Customers

        Trusted by the best teams

      • Blog

        The latest posts and changes

      • Changelog

        See what shipped

      • Press

        Read the latest news

      • Events

        Join us at an event

    • Learn
      • Docs

        Vercel documentation

      • Academy

        Linear courses to level up

      • Knowledge Base

        Find help quickly

      • Community

        Join the conversation

    • Open Source
      • Next.js

        The native Next.js platform

      • Nuxt

        The progressive web framework

      • Svelte

        The web’s efficient UI framework

      • Turborepo

        Speed with Enterprise scale

    • Use Cases
      • AI Apps

        Deploy at the speed of AI

      • Composable Commerce

        Power storefronts that convert

      • Marketing Sites

        Launch campaigns fast

      • Multi-tenant Platforms

        Scale apps with one codebase

      • Web Apps

        Ship features, not infrastructure

    • Tools
      • Marketplace

        Extend and automate workflows

      • Templates

        Jumpstart app development

      • Partner Finder

        Get help from solution partners

    • Users
      • Platform Engineers

        Automate away repetition

      • Design Engineers

        Deploy for every idea

  • Enterprise
  • Pricing
Log InContact
Sign Up
Sign Up
Back to Templates
DeployView Demo

Virtual Event Starter Kit

Jumpstart your virtual event and scale to any size with Next.js and Vercel.
Virtual Event Starter Kit

Amazon IVS Broadcast Web Demo

A tool to stream to Amazon IVS channels from web browsers – no download required.
Amazon IVS Broadcast Web Demo
v0

Build applications with AI

AI SDK

The AI Toolkit for TypeScript

AI Gateway

One endpoint, all your models

Vercel Agent

An agent that knows your stack

Sandbox

AI workflows in live environments

CI/CD

Helping teams ship 6× faster

Content Delivery

Fast, scalable, and reliable

Fluid Compute

Servers, in serverless form

Observability

Trace every step

Bot Management

Scalable bot protection

BotID

Invisible CAPTCHA

Platform Security

DDoS Protection, Firewall

Web Application Firewall

Granular, custom protection

Customers

Trusted by the best teams

Blog

The latest posts and changes

Changelog

See what shipped

Press

Read the latest news

Events

Join us at an event

Docs

Vercel documentation

Academy

Linear courses to level up

Knowledge Base

Find help quickly

Community

Join the conversation

Next.js

The native Next.js platform

Nuxt

The progressive web framework

Svelte

The web’s efficient UI framework

Turborepo

Speed with Enterprise scale

AI Apps

Deploy at the speed of AI

Composable Commerce

Power storefronts that convert

Marketing Sites

Launch campaigns fast

Multi-tenant Platforms

Scale apps with one codebase

Web Apps

Ship features, not infrastructure

Marketplace

Extend and automate workflows

Templates

Jumpstart app development

Partner Finder

Get help from solution partners

Platform Engineers

Automate away repetition

Design Engineers

Deploy for every idea