The general recommendation is: don’t do that. Why should those kind of experiences differ based on the size of the screen?
A useful thought experiment is: how do you expect it to behave on folding phones or tablets, which don’t explicitly fit into the mobile/desktop buckets.
If you really do want this kind of behaviour change to be based on the user-agent of the browser (as the old mobile/desktop modes worked), then we have capabilities.isMobileDevice, which quite literally checks for the word “mobile” in the user-agent string: