📖 View this page in our documentation

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. https://app.yoursite.com)
  2. Detect the GoNative user agent header at your server or load balancer (e.g. Express)
  3. Detect the GoNative user agent in your website JavaScript (e.g. navigator.userAgent)

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

app.get('/', (req, res) => {
  if(req.header('User-Agent').indexOf('gonative') > -1)
    res.send('App version of website')
  else
    res.send('Browser version of website')
})
if (navigator.userAgent.indexOf('gonative') > -1) {
  window.location.href = 'gonative://module/command?parameter=true';
}