FORM_FACOTR
You can use the FORM_FACTOR to determine the device type, however while experimenting this seems to work only in mobile app and not a mobile browser.
To use this module you need to import it like below.
import FORM_FACTOR from '@salesforce/client/formFactor'
The FORM_FACTOR
can have below values based on the type of the device.
Large
- If the device is a desktop.Medium
- If the device is a tablet.Small
- A phone client
navigator.userAgent
This seems to work both with mobile apps and the mobile browser. Add the below method to your LWC JS file