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.
{os}, {arch}, {version}
prefers-color-scheme
<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.
<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>
<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>
| Attribute | Description |
|---|---|
data-repo | Required. GitHub owner/repo |
data-target | CSS selector of existing element to bind |
data-auto | Auto-redirect to download (no button) |
data-fallback | Selector for element to fill with all asset links |
data-version | Pin to a release tag (e.g., v2.1.0) |
data-text | Button text. Use {os}, {arch}, {version} |
data-no-match-text | Text shown when visitor's platform has no match. Default: View all downloads |
data-no-match-url | URL when no match (default: releases page). E.g., a waitlist URL |
data-selector | CSS selector for element to render platform dropdown into |
data-theme | Button theme: auto (follows system), dark, or omit for light |
data-pattern | Regex to match a specific file by name, ignoring platform detection (e.g., \.ipa$) |
data-context-menu | Enable right-click to open releases page (disabled by default) |
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.
https://raw.githubusercontent.com/danielraffel/download-latest/main/download-latest.min.js
Copy download-latest.min.js into your project. Use the configurator above to generate your snippet.
Standalone HTML files demonstrating each use case. View source to see the code.
| Example | Description |
|---|---|
| Minimal | One script tag — auto-creates a download button |
| Custom button | Bind to your own styled button/link |
| URL only | Get the download URL programmatically — no DOM changes |
| All assets list | Show every downloadable file from the release |
| Auto-redirect | Automatically start the download on page load |
| Platform selector | Dropdown 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.
navigator.userAgentData with UA string fallbacksessionStorage).sha256, .sig, .blockmap automatically--dl-bg, --dl-color, --dl-radius) for easy theming