Redirect rule for mobile based on useragent?

I’m also looking for a solution like this. I have a react SPA that is client side rendered. There are different user profile pages. In an SPA that uses client side rendering, if you share these profiles links to Twitter, twitter will use the static meta tags that were built into the application so the social media card shared on twitter will look the same no matter what page you share. But I want the social media card to be different per page. I was wondering if I could redirect the twitter bot (user-agent=Twitterbot/1.0) that scrapes for the social sharing meta data to an endpoint on my backend node server (heroku) that could send an html page with the customized meta data.