#how to identify if the person is mobile or not on an async page?
6 messages · Page 1 of 1 (latest)
🔎 This post has been indexed in our web forum and will be seen by search engines so other users can find it outside Discord
🕵️ Your user profile is private by default and won't be visible to users outside Discord, if you want to be visible in the web forum you can add the "Public Profile" role in id:customize
✅ You can mark a message as the answer for your post with Right click -> Apps -> Mark Solution
(if you don't see the option, try refreshing Discord with Ctrl + R)
What is an ”async page”? I guess you’re referring to a server component.
First of all, you need to do it in client components.
There’s a native property that can indicate the device of user: navigator.userAgent
However, it’s better to determine it with viewport width, since that user agent isn’t reliable
And it depends on what you are trying to do. Like detecting a touch screen device is much easier. “Mobile device” is something abstract and hard to be determined.
It seems that it is not possible to use the navigator on a server component page.
you can only access navigator in a client component. if you want to access the user agent on the server-side, you can use the User-Agent header though as fuma said it's unreliable