In summary, we recommend looking for the string “Mobi” anywhere in the User Agent to detect a mobile device.
If the device is large enough that it's not marked with “Mobi”, you should serve your desktop site (which, as a best practice, should support touch input anyway, as more desktop machines are appearing with touchscreens).
https://developer.mozilla.org/en-US/docs/Web/HTTP/Browser_detection_using_the_user_agent