Unlocking the power of video.js integration with create-next-app in Next.js

I am currently having some difficulty with integrating Video.js in my create-next-app project, specifically in loading the video.js.css file. Here is a snippet of how my component is structured:

import videojs from 'video.js'
import videoStyles from '../node_modules/video.js/dist/video-js.min.css'

export default class VideoPlayer extends React.Component {
  componentDidMount() {
    this.player = videojs(this.videoNode, this.props, function onPlayerReady() {
      console.log('onPlayerReady', this)
    });
  }

  componentWillUnmount() {
    if (this.player) {
      this.player.dispose()
    }
  }

  render() {
    return (
      <div>    
        <div data-vjs-player>
          <video ref={ node => this.videoNode = node } className="video-js"></video>
        </div>
        <style jsx>{videoStyles}</style>
      </div>
    )
  }
}

To load the external CSS file, I am utilizing styled-jsx/css loader.

Answer №1

If you're looking to kickstart your next.js project, take a peek at the example on the next.js github page here. It's a great place to begin.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Exciting Update: Next.js V13 revalidate not triggering post router.push

Currently using Next.js version 13 for app routing, I've encountered an issue with the revalidate feature not triggering after a router.push call. Within my project, users have the ability to create blog posts on the /blog/create page. Once a post is ...

The latest version of Next.js, 11.1.0, does not support monitoring for code changes within the node

In the latest version of Nextjs (11.1.0), there seems to be an issue where code changes in the `node_modules` directory are not being watched, unlike in the previous version (10.2.1). While working on a project with Nextjs 11.1.0, I have tried explicitly ...

The div just won't stay the size I want, no matter what

Here is a snippet of HTML code: <div class="pointwrap"> <div class="imgwrap"> <img src="howtoplay1.jpg" height="101" width="177"/> </div> <div class="textwrap"> Tap Anywhere in the Drop zone to release a ball. ...

What is the best way to place an input box inside a td element so that it occupies the majority of the available space

My code snippet showcases an issue where the input box is not fitting properly inside the table. Running the snippet will provide a clearer understanding. I am attempting to make the input box take up the entire space of the td element within the table. Ho ...

Why does my text keep aligning to the left when I adjust the width, causing my background to remain attached to the text?

When I add a width attribute to my #information h1 id, it seems to override the text-align: center; property and aligns the text/background to the left instead of center. Basically, I need assistance in centering the headers with the appropriate backgroun ...

JavaScript Reference for the HTML DOM Style's height property and revert back to the initial style height

Hey there! I have a simple fix for those who know JavaScript. I have some code that changes the height style on the first click, but I'm looking for a way to revert back to the original height style on the second click. Here's the code snippet: ...

Leveraging remark and rehype plugins in conjunction with nextjs version 13

Exploring nextjs-13, I decided to create a simple blog. Here is the folder structure (skip to 'The Issue' section for the actual problem): app/ page.jsx layout.jsx test.mdx public/ ... styles/ ... mdx-components.jsx next.config.mjs packa ...

Border extends across two separate rows

Let me illustrate my issue with a specific example where I am utilizing a single column with a rowspan: <table border="1" style="width:300px"> <tr> <td rowspan="2">Family</td> <td id="jill">Jill</td> <td>Smi ...

An error occurred as the Serverless Function timed out while attempting to load a dynamic route in Next.js version 13

I have a basic Next.js application with the following route structure: /contentA/ - Static - Initial load: 103 kB /contentA/[paramA]/groups - SSG - Initial load: 120 kB /contentB/[paramA]/[paramB]/[paramC] - SSR (client component) - Initial load: 103 kB ...

I am struggling to layer the boxes using z-index

I have been struggling to find a solution to the problem, but nothing seems to be working. My goal is to create a gradient border for a slideshow on my website, similar to the one showcased in this video. I attempted to use the :before pseudo selector in m ...

What types of mobile browsers, devices, and operating systems are currently compatible with HTML 5, CSS3, and jQuery?

Which mobile browsers, devices, and OS versions are currently compatible with HTML 5, CSS3, and jQuery? ...

Aligning a single component in the center vertically with the appbar positioned at the top of the screen using Material

As a beginner with material UI, I am facing challenges in centering a component both horizontally and vertically on my screen while including an AppBar for navigation at the top. While I have come across solutions like this example using a grid system, i ...

When I try to deploy to Vercel, I often encounter errors in Next.js that I didn't come across while developing. How can I address these issues pro

Recently, as I began deploying to Vercel, an issue arose where I needed to constantly check for errors during the build process. Strict TypeScript errors and messages like "Can't use <img> tag, please use next/image" kept cropping up after each ...

How to incorporate a background image into a hyperlink?

I am working on a class that I have created, which is called .blueButton. It contains some CSS styling that makes it look like a button. .blueButton { /* Styling properties go here */ } To implement this button, I use the following HTML code: <a ...

What is the lowest opacity value allowed in CSS?

When adjusting the opacity value of a button in CSS, I have noticed that even when the opacity is reduced to 0.005, the button remains clickable to some extent. However, when reducing the value to 0.000000000000000000000000000000000001, the button becomes ...

Scalable and movable images contained within a div

Is there a way to enable resizing and dragging for each image? Below is a snippet of code that allows users to select which image they would like to display. They have the option to choose multiple images if they prefer. I am looking to implement functio ...

Experience the magic of a customized cursor that disappears with a simple mouse movement in your website,

I have been experimenting with designing a custom cursor for my website. After finding a design I liked, I made some adjustments to suit my needs. However, an issue I encountered is that when I scroll, the custom cursor also moves away from its original po ...

Various degree of stacking priority ordering

I was faced with a coding dilemma that I couldn't quite figure out. The title may not give much away, but the issue lies within this code snippet: https://jsfiddle.net/bnh3487n/ div { width: 100%; } #wrapper { width: 500px; height: 500px; ...

The upcoming page.tsx export force-dynamic is failing to render dynamically

My dilemma involves a page that I am trying to render dynamically rather than statically. Unfortunately, the commonly suggested solution of simply using: export const dynamic = "force-dynamic"; has not yielded the desired results for me. I have ...

Floating columns in Bootstrap are a great tool for creating

I'm currently working on implementing a specific design layout using Bootstrap, but I've hit a roadblock. Here's the desired layout created with plain CSS: http://jsfiddle.net/n3rLx4n1/ And this is what I've managed to accomplish so f ...