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.

React Server Rendering Errors

See original GitHub issue

I’m trying to import this library into a React component which gets server rendered first then registers client side after. So essentially i need the same React component to work in the browser and in Node. This is causing issues in Node because i get Error: Sorry, the Vimeo Player API is not available in this browser..

Expected Behavior

The Javascript API should allow Node as a browser for some behavior. Even if the API does not support many functions in Node, the API should still allow you to at least import it without errors.

Actual Behavior

When trying to import this library server side in Node I get Error: Sorry, the Vimeo Player API is not available in this browser.

Steps to Reproduce

Import in any file server side.

Issue Analytics

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

github_iconTop GitHub Comments

5reactions
dbismutcommented, Oct 24, 2016

It looks like import Vimeo from '@vimeo/player' triggers a function calling the window element.

The only way I could make this work was to use require instead of import, and call require after the component has been mounted.

As in:

componentDidMount: function() {
  const VimeoPlayer = require('@vimeo/player');
  const player = new VimeoPlayer(this.refs.iframe);
  player.on('play', function() {
    console.log('played the video!');
  });
}
3reactions
randallbcommented, Dec 6, 2016

Is this still desired? I’d be happy to factor out a function to check the page for vimeo elements which would only run if typeof window !== 'undefined' or some other equiv check.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Server Side Rendering Errors
Hi,. I am using MDB React Pro v4.8.7. My team uses SSR for all of our websites but I have been getting errors...
Read more >
Handling the React server hydration mismatch error
How to resolve the server mismatch error when hydrating a shared React component that can be used in client-side only or server-side rendered...
Read more >
Error Boundaries - React
Error boundaries catch errors during rendering, in lifecycle methods, and in constructors of the whole tree below them.
Read more >
React Server-side rendering error due to mismatch between ...
I am working on a React app (18.2.0 version to be exact), which uses server side rendering. On one of the pages, I...
Read more >
Catching Server-side Rendering Errors in React JSS Apps
Error handling in React will be handled differently on a client and a server-side. Let's start with the first one.
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