9a21c705b7
The @kinescope/react-kinescope-player library accesses browser APIs (window/document) during server-side rendering. In Next.js App Router, client components are SSR-rendered on full page loads (direct URL, refresh) but not on RSC navigations. This caused a 500 error for all lessons with a kinescopeId when accessed directly. Fix: defer rendering KinescopeReactPlayer until after mount with useEffect + useState(false), so it only runs in the browser.
28 lines
631 B
TypeScript
28 lines
631 B
TypeScript
"use client";
|
|
|
|
import { useEffect, useState } from "react";
|
|
import KinescopeReactPlayer from "@kinescope/react-kinescope-player";
|
|
|
|
interface Props {
|
|
videoId: string;
|
|
poster?: string;
|
|
}
|
|
|
|
export function KinescopePlayer({ videoId, poster }: Props) {
|
|
const [mounted, setMounted] = useState(false);
|
|
useEffect(() => setMounted(true), []);
|
|
|
|
return (
|
|
<div className="w-full aspect-video" style={{ border: "2px solid var(--border)" }}>
|
|
{mounted && (
|
|
<KinescopeReactPlayer
|
|
videoId={videoId}
|
|
width="100%"
|
|
height="100%"
|
|
poster={poster}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|