[4.7.1] - Detect If HTML5 Version Of Our Game Is Running On Mobile Browser?

Godot Version

v4.7.1.stable.official [a13da4feb] Linux desktop x86_64

Question

How can we detect if the HTML5 version of our game is running on mobile browser?
We want to do the above and show a non-compatibility screen for mobile devices.
We do not want to the game to run on mobile browsers as we donโ€™t support it.
Let us know, thanks!

if OS.has_feature("web_android") or OS.has_feature("web_ios"):

That should work, thank you!

Even though this is explicitly stated in the documentation it did not work for me when I have previously tried it. I usually then used the JavaScriptBridge API (JavaScriptBridge โ€” Godot Engine (stable) documentation in English) to natively check the platform. You of course then need to check that you are actually running on web before interacting with that API but OS.get_name() == "Web" did work for me.