Skip to content
Advertisement

How do I tell if a user is using Brave as their browser?

I have been messing around with the Brave browser (https://www.brave.com/), an I cannot figure out how to determine how if a user is using Brave. I used a simple document to output the user agent:

<script>document.write(navigator.userAgent);</script>

and I get:

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.108 Safari/537.36

which doesn’t really help me in my situation. Does anyone know how to determine anyone using Brave in PHP or JavaScript? Thanks!

Advertisement

Answer

Kohjah Breese’s solution isn’t working to detect Brave on Android (e.g. Chrome is detected as Brave). But as he said “If you search DuckDuckGo for [what’s my user agent] they will return Brave.” Then you can use the API of Duckduckgo to know if they browser is Brave :

var request = new XMLHttpRequest()

request.open('GET', 'https://api.duckduckgo.com/?q=useragent&format=json', true)

request.onload = function () {
  var data = JSON.parse(this.response)
  var isBrave = data['Answer'].includes('Brave');
  if(isBrave){
    console.log( isBrave );
  }
}

request.send()
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement