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.

Server-Side Rendering Support

See original GitHub issue

Is your feature request related to a problem? Please describe.

ply-react doesn’t really work with static site generators like Gatsby. It will produce the good ol’ “document is not defined” error.

Describe the solution you’d like

An out-of-the-box SSR implementation, or at least some documentation on workarounds.

Describe alternatives you’ve considered

I’ve been using loadable-component to circumvent this, but it no longer works in Gatsby v4.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6

github_iconTop GitHub Comments

1reaction
qinyiyaocommented, Nov 14, 2021

I ended up using React Suspense, which has no SSR support right now, but at least it works.

Guide from Gatsby:

import React from "react"

const ClientSideOnlyLazy = React.lazy(() =>
  import("../components/ClientSideOnly")
)
const MyPage = () => {
  const isSSR = typeof window === "undefined"

  return (
    <VideoContainer>
      {!isSSR && (
        <React.Suspense fallback={<div />}>
          <ClientSideOnlyLazy />
        </React.Suspense>
      )}
    </VideoContainer>
  )
}

//A wrapper holds the container in place to prevent layout shifting.
const VideoContainer = styled.div`
  aspect-ratio: 16 / 9;
`
1reaction
realamirhecommented, Oct 23, 2021

I believe our package behavior might face some problems in SSR and we may want to replace the useEffect with something like useIsomorphicLayoutEffect. But this is known open Plyr issue #1909.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is server-side rendering: definition, benefits and risks
Server -Side Rendering (SSR) is an approach to rendering content for the website. Learn the benefits, drawbacks and frameworks of server-Side ...
Read more >
What is server-side rendering and how does it improve site ...
Server -side rendering (SSR) addresses the performance and search engine optimization issues of single-page JavaScript applications.
Read more >
Client-side vs. server-side rendering: why it's not all black and ...
Server -side rendering is the most common method for displaying information onto the screen. It works by converting HTML files in the server...
Read more >
Take advantage of these 5 benefits of server-side rendering
1. Improved data security and PIPA compliance · 2. Improve page load time with minimized network latency · 3. Predictable server-side processing ...
Read more >
The Benefits of Server Side Rendering Over Client ... - Medium
SSR throughput of your server is significantly less than CSR throughput. For react in particular, the throughput impact is extremely large.
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