download-latest

Add a download button that auto-detects your visitor's OS and links to the latest binary from your GitHub releases. One script tag, no dependencies.

Configurator

https://github.com/
Advanced
Regex matched against all release asset names — ignores visitor's OS/arch. First match wins.
Use {os}, {arch}, {version}
Auto adapts to the visitor's light/dark preference via prefers-color-scheme
Shown when visitor's platform has no matching binary
Where to link when no binary matches (e.g., a waitlist page)
When enabled, right-click / long-press on the button opens the GitHub releases page instead of the browser context menu
Adds a dropdown next to the button so visitors can pick a different platform
Platforms (optional)
Uncheck a platform to exclude it. Add a regex pattern to override the default asset matching.
Files not matched to any platform above (e.g., source archives, Arch Linux packages)

Quick Start

One script tag

<script
  src="https://cdn.jsdelivr.net/gh/danielraffel/[email protected]/download-latest.min.js"
  data-repo="your-org/your-app"
></script>

This inserts a download button that links to the right asset for each visitor's platform.

Bind to your own button

<a id="dl" href="#">Download</a>
<script
  src="https://cdn.jsdelivr.net/gh/danielraffel/[email protected]/download-latest.min.js"
  data-repo="your-org/your-app"
  data-target="#dl"
></script>

Programmatic

<script src="https://cdn.jsdelivr.net/gh/danielraffel/[email protected]/download-latest.min.js"></script>
<script>
  const dl = new DownloadLatest({ repo: 'your-org/your-app' });
  dl.get().then(r => console.log(r.url));
</script>

Configuration

AttributeDescription
data-repoRequired. GitHub owner/repo
data-targetCSS selector of existing element to bind
data-autoAuto-redirect to download (no button)
data-fallbackSelector for element to fill with all asset links
data-versionPin to a release tag (e.g., v2.1.0)
data-textButton text. Use {os}, {arch}, {version}
data-no-match-textText shown when visitor's platform has no match. Default: View all downloads
data-no-match-urlURL when no match (default: releases page). E.g., a waitlist URL
data-selectorCSS selector for element to render platform dropdown into
data-themeButton theme: auto (follows system), dark, or omit for light
data-patternRegex to match a specific file by name, ignoring platform detection (e.g., \.ipa$)
data-context-menuEnable right-click to open releases page (disabled by default)

Hosting

jsDelivr CDN (recommended)

https://cdn.jsdelivr.net/gh/danielraffel/[email protected]/download-latest.min.js

Pin to a version (@1.0.0) or track latest (@main). Free, no setup required — jsDelivr serves any public GitHub repo automatically.

Raw GitHub

https://raw.githubusercontent.com/danielraffel/download-latest/main/download-latest.min.js

Self-hosted

Copy download-latest.min.js into your project. Use the configurator above to generate your snippet.

Examples

Standalone HTML files demonstrating each use case. View source to see the code.

ExampleDescription
MinimalOne script tag — auto-creates a download button
Custom buttonBind to your own styled button/link
URL onlyGet the download URL programmatically — no DOM changes
All assets listShow every downloadable file from the release
Auto-redirectAutomatically start the download on page load
Platform selectorDropdown menu grouped by OS with all available assets

Each example uses rustdesk/rustdesk as a demo repo. The configurator above generates ready-to-use snippets for any repo.

How It Works