Developer DemoTry it live: Load https://median.dev/clipboard/ in your Median app to test clipboard functionality during development.
median.clipboard API exposes two methods:
Both iOS and Android are supported.
clipboard.get() supports two async patterns: Promises and named callback functions.
Implementation guide
Writing to the clipboard
Usemedian.clipboard.set() to copy a string to the system clipboard. This is the equivalent of a user pressing Ctrl+C / Cmd+C on their desktop browser.
Example use case: Providing a “Copy to clipboard” button for invite codes, promo codes, links, or other content.
Reading from the clipboard
Usemedian.clipboard.get() to retrieve the current clipboard contents. This method is asynchronous and returns a result object with either a data property (on success) or an error property (on failure).
Choose the pattern that best fits your codebase: promises or callbacks.
Option 1: Promise (recommended)
Promises integrate cleanly with async/await and modern JavaScript workflows.Option 2: Named callback
Named callbacks are useful when integrating with legacy codebases or when you need the function to be callable from native app contexts. Pass the name of your callback function as a string using the callback key:clipboard.get() patterns return the same result object:
Always check for
result.data before using the value, and handle the result.error case.
Platform behavior
- iOS: On iOS 14+, the system may display a notification banner informing the user that your app has accessed the clipboard. This is an OS-level behavior and cannot be suppressed.
- Android: Clipboard read access may be restricted on Android 10+ when your app is not in the foreground. Ensure clipboard reads are triggered by an explicit user action.