player icon indicating copy to clipboard operation
player copied to clipboard

Plyr Layout causing Hydration error in NextJS server components

Open dottodot opened this issue 10 months ago • 1 comments

Current Behavior:

The default layout doesn't have this issue but when using the Plyr Layout I get

Hydration failed because the server rendered HTML didn't match the client. As a result this tree will be regenerated on the client. This can happen if a SSR-ed Client Component used:

The error seems to relate to the class name being undefined

                            <Primitive.div className={undefined} ref={function}>
                              <div
+                               className={undefined}
-                               className={"plyr plyr--full-ui plyr--video "}
                                ref={function}

Steps To Reproduce:

Here's a stackblitz that replicates the issue

https://stackblitz.com/edit/stackblitz-starters-nudlw6qf?file=package.json

Anything Else?

Image

dottodot avatar Mar 15 '25 10:03 dottodot

Got errors in production with Vidstack Player, for me the player components was breaking during the server rendering. I solved the issue by using this in server mode :

  if (typeof window == "undefined") {
    return null
  }

MatteoGauthier avatar Apr 16 '25 15:04 MatteoGauthier