Detecting App Usage

You may choose to serve a different version of your website through your app. You can then control when the JavaScript Bridge commands are available, and also provide different layouts in the app versus the browser, e.g. limit the pages that are linked and accessible within the app, remove your website navigation menus in favor of a native navigation menu, remove a website footer to improve the app UI, etc.

To detect when your website is showing through your app:

  1. Use a different URL for your app (e.g.
  2. Detect the GoNative user agent in your website JavaScript (e.g. navigator.userAgent)
  3. Detect the GoNative user agent header at your server / web application routes (e.g. Express)

Your app will append the following strings to the end of the device default user agent:
iOS app: GoNativeIOS/1.0 gonative
Android app: GoNativeAndroid/1.0 gonative

//JavaScript on your website:
if (navigator.userAgent.indexOf('gonative') > -1) {
  //run a JavaScript Bridge command only when in the app
  window.location.href = 'gonative://module/command?parameter=true';
  //hide/show elements within the app
// Node.JS Express App
app.get('/', (req, res) => {
  if(req.header('User-Agent').indexOf('gonative') > -1)
    res.send('App version of website');
    res.send('Browser version of website');

Next Steps