Recently release version of twilio-video 2.4.0 has updated isSupported and introduced navigator to make a few checks, this introduced a problem when it comes to Server side rendering (for example using React in NextJS) as it does not exist server side.
To reproduce this error I have made a small example app:
https://github.com/lmatheus/twilio-video-ssr-is-supported
you can run yarn then yarn dev and open a browser using http://localhost:3000
Expected behavior:
navigator not defined should not cause isSupportedto break server side rendered applications when imported
Actual behavior:
When imported in a server side rendered React app
ReferenceError: navigator is not defined
Suggestion:
checking navigator been defined before calling it typeof navigator !== 'undefined'
Hi @lmatheus ,
Thanks for reporting this issue. I will confirm this issue using the app you have provided and do the needful. However, isSupported is meant to be run on the browser to see if it is officially supported by the SDK, so it doesn't really make sense to use it on the server side. I recommend that you update your code to use isSupported on the browser.
In the meantime, I will file a ticket to have isSupported return false when it runs on the server side.
Thanks,
Manjesh Malavalli
JSDK Team
Just for clarity - there isn't a workaround for this at the moment because isSupported gets called when the module is imported (see here), so can't just "not be used on the server"
Seeing this too, I cannot upgrade because of this unless I use something like patch-package. James is correct as I have never explicitly called isSupported but it is called on import so I do not have the option of not using this when using SSR
Hi @Tyler-Churchill , @jamessharp , @lmatheus ,
The fix is scheduled to be released in the upcoming release (2.5.0). We are going to cut a release candidate for QA some time this week. I'll reach out when the release is available.
Thanks,
Manjesh Malavalli
JSDK Team
Hi @Tyler-Churchill , @jamessharp , @lmatheus ,
twilio-video.[email protected] is now available. Please try it out and let me know if this solves the issue for you. I'll close the issue, but we can continue the discussion here.
Thanks,
Manjesh Malavalli
JSDK Team
Most helpful comment
Just for clarity - there isn't a workaround for this at the moment because
isSupportedgets called when the module is imported (see here), so can't just "not be used on the server"