How to detect if a user is on mobile (user agent)

I have created a mobile-optimized page, which is a scaled down representation of another page.

Due to the changes, I’d like button actions to be slightly different when the user is using this view.

Is there a way to detect if the user agent is mobile?

Theres no way to detect if a user is on mobile vs computer. The way I get around this is how I set up my pages. On mobile, you can choose to have the 4 main pages on the bottom as tabs. I specifically set up those first 4 pages for mobile and then either nest the other pages within those, or have the other pages below those first 4 pages.

Screen Shot 2023-10-12 at 3.36.02 PM

There definitely may be a better way around this, but this is the solution I came up with.
The computer pages are accessible to mobile users still, just helps lead the user to the right pages for them.