question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[V2] | Build Fails on Server build | (undefined) API is not available in this browser.

See original GitHub issue

🐛 Bug Report

Error: Sorry, the Vimeo Player API is not available in this browser.

This works well in the dev mode but the build throws an error.

Have you read the Contributing Guidelines on issues?Yes

I am trying to import and use a React component in the .mdx files in the docs folder.

abc.mdx import Vimeo from ‘@u-wave/react-vimeo’; <Vimeo video="https://vimeo.com/1234567789" responsive={true} width={640} height={480} />

To Reproduce

(Write your steps here:)

  1. Scaffold a v2 docusaurus project
  2. Install @u-wave/react-vimeo from npm and import it in docs/doc2.mdx file
  3. npm start -> starts the build and video is displayed in the component
  4. Try to build the project npm run build -> errors out

Expected behavior

The build version should be successful and should behave like the dev version.

(Write what you thought would happen.)

Actual Behavior

The prod build error out

(Write what happened. Add screenshots, if applicable.) image

Reproducible Demo

https://github.com/ramakrishnan3/ducusaurus-bug-report

-> clone the repo -> npm i -> npm start - successful -> npm run build - errors out (Paste the link to an example repo, including a siteConfig.js, and exact instructions to reproduce the issue.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
davodeycommented, Jan 25, 2020

Probably the video component is non-compatible with server-side rendering because it uses browser-specific APIs (e.g. window), which isn’t available on the server. This is not specific to Docusaurus. You could try to only render the component in a browser environment by doing

{typeof window !== ‘undefined’ && }

@yangshun I’ve been hacking away at v2 and ran into something similar, and after several days I came across this thread. This fixed the issue I had, and now I can go out for a beer 😃 cheers!

0reactions
taylorreececommented, Jan 19, 2021

This is pretty late, but for anyone hitting this, I stopped using the @u-wave/react-vimeo package, and instead added my own component to my Docusaurus project in src/components/vimeo.jsx:

import React from "react";
import { makeStyles } from "@material-ui/core/styles";

const useStyles = makeStyles((theme) => ({
  root: {
    paddingTop: "56.25%",
    position: "relative",
  },
  vimeoIframe: {
    position: "absolute",
    top: 0,
    left: 0,
    width: "100%",
    height: "100%",
  },
}));

const Vimeo = ({ video, title }) => {
  const classes = useStyles();
  const vimeoSource = `https://player.vimeo.com/video/${video}`;

  return (
    <div className={classes.root}>
      <iframe
        src={vimeoSource}
        className={classes.vimeoIframe}
        title={title}
        frameBorder="0"
        allow="autoplay; fullscreen; picture-in-picture"
        data-ready="true"
      />
    </div>
  );
};

export default Vimeo;

Then, I can just do this in any markdown docs file:

import Vimeo from "@site/src/components/vimeo";

## Some Header

Here's an explainer video:

<Vimeo video="12345678" title="An explainer video" />

Here's some other stuff

It doesn’t give you all the hooks that @u-wave/react-vimeo does, but it at least embeds a vimeo video into your documentation that resizes reactively, lets you do fullscreen, etc.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Swagger not loading - Failed to load API definition: Fetch error ...
First, take a look the link below just to check if your setup is ok: Add Swagger(OpenAPI) API Documentation in ASP.NET Core 3.1....
Read more >
Troubleshooting Cloud Functions - Google Cloud
Function deployment fails due to Cloud Build not supporting VPC-SC. Cloud Functions uses Cloud Build to build your source code into a runnable...
Read more >
API - ESBuild
API. The API can be accessed in one of three ways: on the command line, in JavaScript, and in Go. The concepts and...
Read more >
Error Messages | Maps JavaScript API - Google Developers
Map Loading Errors; Maps JavaScript API Error Codes. Checking Errors in Your Browser; Handling unsupported browsers; If your code still isn't working.
Read more >
Troubleshooting Omnibus GitLab installation issues
This error is thrown when /etc/gitlab/gitlab.rb configuration file contains configuration that is invalid or unsupported. Double check that there are no ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found