Skip to content
AppQR

One download link for Windows, macOS and Linux

Short answer

Use one address that checks which system the visitor is on and sends them to the matching download. You can do it with a few lines of JavaScript on your download page, or with a small redirect on a server. A hosted smart link does the same without code and also works where scripts cannot run, such as a README or a printed QR code.

Last updated

A project that runs on Windows, macOS and Linux usually ends up with three download buttons, or a page that asks people to choose. That works on a website, but not everywhere a link is shared. A README, a slide, a forum post or a printed poster has room for one link, and it cannot ask any questions.

The problem: one place, three downloads

What you want is a single address, such as https://example.com/download, that:

  • sends Windows users to the installer;
  • sends Mac users to the disk image or the Mac App Store;
  • sends Linux users to Flathub, the Snap Store or your AppImage;
  • sends everyone else, including phones, to a page that lists every option.

Browsers say which system they run on with every request, in the User-Agent header. Chromium-based browsers (Chrome, Edge and others) also send a shorter Sec-CH-UA-Platform header, and offer the same value to scripts as navigator.userAgentData.platform. Safari and Firefox do not support userAgentData, so you need the user agent as well.

How do I detect the visitor’s operating system in JavaScript?

If you have a download page, a few lines of JavaScript can point its main button at the right file. Everyone without JavaScript, or on a system you do not recognise, keeps the plain link to the full list.

<a id="download" href="/download/all">Download</a>

<script>
  const downloads = {
    windows: 'https://github.com/example/app/releases/latest/download/App-Setup.exe',
    mac: 'https://github.com/example/app/releases/latest/download/App.dmg',
    linux: 'https://flathub.org/apps/org.example.App',
  };

  function desktopSystem() {
    const ua = navigator.userAgent;
    const platform = navigator.userAgentData?.platform ?? '';
    // Phones and tablets first: Android user agents also contain "Linux".
    if (platform === 'Android' || /Android|iPhone|iPad|iPod/.test(ua)) return null;
    if (platform === 'Windows' || /Windows NT/.test(ua)) return 'windows';
    if (platform === 'macOS' || /Macintosh/.test(ua)) {
      // An iPad asking for desktop sites says "Macintosh" but has a touch screen.
      return navigator.maxTouchPoints > 1 ? null : 'mac';
    }
    // Chromebooks say "X11; CrOS"; they cannot run a Linux download as is.
    if (platform === 'Linux' || (/Linux|X11/.test(ua) && !/CrOS/.test(ua))) return 'linux';
    return null;
  }

  const system = desktopSystem();
  if (system) document.getElementById('download').href = downloads[system];
</script>

The releases/latest/download/<file name> addresses are a GitHub feature: they always point at that file in your newest release, as long as the file name stays the same from release to release.

If the link has to work outside your website, it needs to run on a server instead. How to redirect a URL by device has a small server-side version.

How reliable is operating system detection?

  • It only works where code can run. A README, a PDF or a QR code cannot run your script. For those you need an address that redirects on a server.
  • Mac processors cannot be told apart. Mac browsers report an Intel Mac user agent on Apple Silicon too. Ship a universal build, or link to a page with both.
  • Linux is many systems. The user agent does not say which distribution, package format or processor the visitor has. A Flathub or Snap Store page, or a releases page that lists the AppImage, .deb and .rpm, is safer than a direct file.
  • Windows versions look alike. Windows 11 browsers still say Windows NT 10.0, and the user agent does not reliably say whether the PC is ARM or x86.
  • An iPad can look like a Mac. Safari on iPad usually asks for the desktop version of sites and sends a Mac user agent. The maxTouchPoints check above catches this in the browser; a server cannot. See Why an iPad is detected as a Mac.
  • Always keep a way to choose. Detection is a guess. Put a “Other systems and versions” link next to the button.

Can I do it without code?

A hosted smart link is a short address run by a service. You enter one destination per system, and the service’s server reads each visitor’s system and redirects them. Because the decision happens on the server, the same link works in a README, on a slide or as a printed QR code. You can usually change the destinations later without changing the link.

When you pick a service, check how it treats systems it cannot identify, whether there is a page or advert before the redirect, and what happens to your links if you stop paying.

How AppQR does it

An AppQR smart link has one destination each for Windows, Mac, Linux, Android and iPhone and iPad, plus a default for everything else. Routing for all of them is on every plan, including Free; see Pricing.

  • AppQR reads the system from the request on its server. It does not run code on the visitor’s device, and there is no page in between.
  • Linux visitors go to whatever you enter: a Flathub or Snap Store page, an AppImage, or your own download page.
  • Chromebooks, consoles and anything AppQR cannot identify go to the default.
  • An iPad that asks for desktop sites is treated as a Mac, because it sends a Mac user agent.
  • Test this link in the dashboard shows which address each kind of visitor will get.

How platform routing works has the full rules.

Questions people also ask

Can a GitHub README detect the visitor's operating system?

No. A README cannot run scripts, so a link in it always goes to the same address. To send each system to its own download, the link has to point at something that decides, such as your own download page, a small redirect on a server, or a hosted smart link.

Can I tell an Apple Silicon Mac from an Intel Mac?

Not reliably from the user agent. Mac browsers report the same Intel Mac user agent on both kinds. The simplest answer is a universal build, or a download page that lets the visitor pick.

Where should a Linux download link go?

Usually to a page rather than a file, because the link cannot tell which distribution or processor the visitor has. Your Flathub or Snap Store page, or a releases page that lists the AppImage and packages, works for most people.

What happens on a phone?

That is up to you. A desktop-only app should send phones to a page that explains it is for computers, or that offers to email the link. If you also have a mobile app, send Android and iPhone to their stores.

Does AppQR send people straight to a file?

It sends them to whatever address you enter for each system. That can be a file, a store page or a download page. There is no page or advert in between.

Try it with your own links

One short link and QR code that sends each device to its own page. Free for 2 links, with no card and no time limit.