#how to identify if the person is mobile or not on an async page?

6 messages · Page 1 of 1 (latest)

tight sapphire
#

I'm trying to see if the person is on mobile or desktop with javascript on an async page, but it can't return me, how to do it?

cursive trellisBOT
#

🔎 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)

vast pewter
#

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.

tight sapphire
quaint jasper