Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Browser

Browser and platform detection for web applications.

Browser contexts use these attributes:

AttributeTypeSourceExamplePrivateNotes
keyStringCompositechrome-120.0.6099.109FALSEBrowser Identifier + Version String
userAgentStringNavigator APIMozilla/5.0…FALSEBrowser’s user-agent string
appNameStringBrowser DetectionChromeFALSEBrowser app name (Firefox, Safari, Chrome)
/app/firefox/versionStringBrowser Detection121.0FALSEFirefox version
/app/chrome/versionStringBrowser Detection120.0.6099.109FALSEChrome version
/app/safari/versionStringBrowser Detection17.2FALSESafari version
/locale/tagStringNavigator APIenFALSELanguage code (en, es, de)

Implementation example

Implement a browser context like this:

const browserContext = {
  kind: "browser",
  key: `${browserName}-${browserVersion}`,
  userAgent: navigator.userAgent,
  appName: browserName,
  app: {
    [browserName.toLowerCase()]: {
      version: browserVersion
    }
  },
  locale: {
    tag: navigator.language.split('-')[0]
  }
};

Use cases

Roll out by browser to reduce browser-specific issues

Use this when you start a rollout on browsers where you have strong test coverage. For example, roll out to Chrome at 20% while Safari remains at 5% until you verify compatibility.

Progressive enhancement based on browser capabilities

Use this when you enable features that require modern browser APIs. For example, enable WebGL-based visualizations only in browsers that support it. You can also use Service Workers only in compatible browsers.

Browser version targeting

Use this when your features require minimum browser versions. For example, enable features that use CSS Grid only on browsers with full Grid support. Use modern JavaScript features only on browsers with ES2020+ support.

Localization testing

Use this when you roll out internationalization features. For example, enable new translations for users with specific locale settings. You can also test RTL layout for Arabic or Hebrew language users.