Check out example codes for "avoid bots hitting server apache2". It will help you in understanding the concepts better.

Code Example 1

<Directory /var/www/html>
        #Header set Access-Control-Allow-Origin "*"
        BrowserMatchNoCase "Baiduspider" bots
        BrowserMatchNoCase "HTTrack" bots
        BrowserMatchNoCase "Yandex"  bots
        BrowserMatchNoCase "AhrefsBot" bots
        BrowserMatchNoCase "exabot"  bots
        BrowserMatchNoCase "MJ12bot" bots
        BrowserMatchNoCase "dotbot"  bots
        BrowserMatchNoCase "gigabot" bots
        BrowserMatchNoCase "Visbot" bots
        BrowserMatchNoCase "SemrushBot" bots
        BrowserMatchNoCase "SpammerRobot" bots
        BrowserMatchNoCase "SecurityHoleRobot" bots

        Options Indexes FollowSymLinks

        AllowOverride none
        Order allow,deny
        Allow from all
        Deny from env=bots
        Require all granted

Learn ReactJs, React Native from akashmittal.com