+ Start a Discussion
Rajneesh Ranjan 23Rajneesh Ranjan 23 

How we can identify if lightning web component (LWC) is running in Salesforce mobile app or in desktop browser?

How we can identify if lightning web component (LWC) is running in Salesforce mobile app or in desktop browser?
Best Answer chosen by Rajneesh Ranjan 23
Khan AnasKhan Anas (Salesforce Developers) 
Hi Rajneesh,

Greetings to you!

$Browser Global Value Provider is not yet available in LWC and there is no equivalent of $Browser Aura global value provider in LWC. It might be available in future releases.

https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.migrate_gvps

You can use CSS media queries (https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries) and Element.getBoundingClientRect (https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) to make component adapt to the space available on the screen.

Reference: https://salesforce.stackexchange.com/questions/252853/is-there-an-equivalent-to-a-getbrowser-formfactor-in-lwc

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas

All Answers

Khan AnasKhan Anas (Salesforce Developers) 
Hi Rajneesh,

Greetings to you!

$Browser Global Value Provider is not yet available in LWC and there is no equivalent of $Browser Aura global value provider in LWC. It might be available in future releases.

https://developer.salesforce.com/docs/component-library/documentation/lwc/lwc.migrate_gvps

You can use CSS media queries (https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries) and Element.getBoundingClientRect (https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect) to make component adapt to the space available on the screen.

Reference: https://salesforce.stackexchange.com/questions/252853/is-there-an-equivalent-to-a-getbrowser-formfactor-in-lwc

I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas
This was selected as the best answer
Rajneesh Ranjan 23Rajneesh Ranjan 23
Thanks for helping me Khan Anas. I really appreciate your time.

Then I think, one option might be wrapping the LWC inside Aura component and send this parameter from Aura component to inner LWC. That way it should work I guess.

Regards,
Rajneesh