-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Seamless integration with Nextjs #2
Comments
Thank you for the report. I've tried several idea's, the final result can be see in PR #3. The first idea I had was to make shaka-player-react "importable" by next.js, but this failed as global objects like "document" and "window" are not recognized by node. I quickly gave up on the idea for the following reasons:
With these comments in mind, I've managed to make it work by relying on import dynamic from 'next/dynamic';
const ShakaPlayer = dynamic(
() => import('shaka-player-react'),
{ ssr: false },
);
// Use <ShakaPlayer ... /> as if it was directly imported from shaka-player-react Unless I've missed something, this feels like a reasonable approach to use Let me know what you think. |
I'd probably agree with you in everything. Great effort, thanks! =] Feel free to close the issue as soon as it gets documented. |
As we've discussed at shaka-project/shaka-player#2163, the component may not be working right away with https://github.com/zeit/next.js, probably because of Shaka's non support for SSR.
There's a sample here loading the Shaka dynamically so it's possible to avoid Shaka that non support: https://github.com/amit08255/shaka-player-react-with-ui-config/tree/master/nextjs-shaka-player
It may be interesting to handle this in the component.
The text was updated successfully, but these errors were encountered: