How to Add Copy to Clipboard to Your Expo App

DavidDavid October 20, 2026 7 min read

How to add copy to clipboard to your Expo app, in short

Use expo-clipboard. Install it with npx expo install expo-clipboard, import it with import * as Clipboard from 'expo-clipboard', and call await Clipboard.setStringAsync(value) when the user taps a copy button. Then tell the user it worked, with a short "Copied" label or toast. To read what is on the clipboard, call await Clipboard.getStringAsync(), which resolves to a string.

That covers the copy button most apps need: a referral code, an invite link, an order number, a generated caption. The parts that decide whether it feels right are the rest: what happens on iOS when your app reads the clipboard, the native paste button, copying images and links, and keeping secrets out of keyboard previews on Android. That is what this guide covers.

Step 1: Install expo-clipboard

  1. Install: npx expo install expo-clipboard. Using expo install picks the version that matches your SDK.
  2. Import: import * as Clipboard from 'expo-clipboard'.
  3. Start testing in Expo Go. The expo-clipboard reference lists it as included in Expo Go, on Android, iOS and web.
  4. No config plugin or permission entry to add for copying. Writing to the clipboard does not show a prompt.

Compare that with device features like the camera or location, where you need usage descriptions and a permission request; see [how to request permissions in your Expo app](/blog/how-to-request-permissions-in-your-expo-app) for those. The clipboard only gets interesting when you read from it, which is Step 3.

Step 2: Build the copy button

A minimal handler: const [copied, setCopied] = useState(false); const copyCode = async () => { await Clipboard.setStringAsync(inviteCode); setCopied(true); setTimeout(() => setCopied(false), 2000); }. Render the button label as copied ? 'Copied' : 'Copy code'. The feedback matters more than it looks: the clipboard is invisible, so without it users tap twice, or leave unsure anything happened.

  • Copy exactly what the user expects. Trim whitespace and leave out labels like "Code:" so the pasted value works in the next app.
  • Show the value next to the button so the user can see what they are copying.
  • Add a light tap of haptic feedback on success; it pairs well with copy actions. See [how to add haptic feedback to your Expo app](/blog/how-to-add-haptic-feedback-to-your-expo-app).
  • Make the value itself selectable as a fallback with the selectable prop on the Text component, so long-press copy still works.

Step 3: Read the clipboard, and the iOS paste prompt

Reading is where iOS changes the rules. Apple's UIPasteControl documentation says that in iOS 16 and later, programmatic pasting raises an alert that asks the user for approval before the app gets the clipboard contents. So if your screen calls getStringAsync on load, iPhone users can see a system prompt the moment they arrive, before they have done anything. That feels intrusive, and it is the most common clipboard mistake in shipped apps.

The expo-clipboard reference adds the second half of the problem: on iOS 16 and later, if the user denies paste permission, getStringAsync returns an empty string, and there is no way to tell an empty clipboard from a denied one. getImageAsync and getUrlAsync return null in the same situation. Your code has to treat "nothing came back" as a normal outcome, not an error.

Reading the clipboard in Expo

MethodReturnsWhen nothing is available or access is denied
getStringAsync()Promise of a stringEmpty string
getImageAsync({ format: 'png' })Promise of a ClipboardImage or nullnull
getUrlAsync() (iOS)Promise of a string or nullnull
hasStringAsync() / hasImageAsync()Promise of a booleanfalse

My recommendation: only read the clipboard in direct response to the user, such as a Paste button they tapped, never automatically on screen load. On web, the reference notes that reading also asks the user for permission to see text and images copied to the clipboard, so the same rule keeps your app consistent across platforms.

Step 4: Use the native paste button on iOS

If pasting is central to a screen, such as pasting a link to import or a code to redeem, use ClipboardPasteButton. It renders Apple's UIPasteControl, which, per Apple's docs, lets the user paste without the permission prompt, because the tap on the system button is the approval.

  • Check Clipboard.isPasteButtonAvailable first. The reference says it requires at least iOS 16 and the component renders nothing when it is not available.
  • Give it a height and width through the style prop. The reference warns the button will not appear without them.
  • Do not set backgroundColor, color or borderRadius in style. Apple restricts customizing it; use the backgroundColor, foregroundColor, cornerStyle and displayMode props instead. The word "Paste" and the icon cannot be changed.
  • Handle onPress(data) and check data.type, which is 'text' or 'image'. Use acceptedContentTypes to limit what activates the button, and do not combine 'plain-text' with 'html', which the docs say makes all text be treated as html.
  • Render a normal Paste button that calls getStringAsync as the fallback when isPasteButtonAvailable is false, for example on Android.

Step 6: Handle secrets carefully

If your app copies a password, one-time code, API token, recovery key or payment detail, pass the Android sensitive flag: await Clipboard.setStringAsync(token, { android: { isSensitive: true } }). The expo-clipboard reference says this sets Android's EXTRA_IS_SENSITIVE flag, which on Android 13 and later stops the clipboard preview overlay from showing the content and signals keyboards to avoid showing it in clipboard suggestions. setImageAsync takes the same option.

Mistakes that make clipboard features feel broken

  • Reading the clipboard on screen load, which can trigger the iOS paste prompt before the user did anything.
  • Treating an empty string from getStringAsync as an error. On iOS 16 and later it can simply mean the user denied the paste prompt.
  • Copying with no visible confirmation.
  • Rendering ClipboardPasteButton without a width and height, so it never appears.
  • Styling the paste button with backgroundColor or borderRadius in style instead of its own props.
  • Using the old Clipboard export from react-native. React Native's docs mark it as removed and point to community packages; in an Expo app, use expo-clipboard.
  • Copying tokens or codes without android.isSensitive, so they show up in keyboard clipboard previews.

Have Claude Code set it up for you

Open your project in the Claude Code desktop app and be specific about where reads happen. Left to its own judgment, AI-written code often reads the clipboard in a useEffect to "helpfully" prefill a field, which is exactly what triggers the iOS prompt. A prompt that covers it:

Then add a line to your [CLAUDE.md](/blog/claude-md-for-expo-apps) such as "clipboard uses expo-clipboard; only read the clipboard on an explicit user tap; secrets use android.isSensitive" so a later session does not undo it. Test on a real iPhone running iOS 16 or later: tap Paste, deny the prompt once, and make sure the screen handles it calmly.

The short version

To add copy to clipboard to your Expo app: install expo-clipboard, call setStringAsync from a button press, and show a clear "Copied" confirmation. Only read the clipboard when the user taps something, expect an empty string when iOS paste access is denied, use ClipboardPasteButton where it is available, and mark secrets with android.isSensitive.

If you are building your first iOS app with Claude Code and Expo and want a second pair of eyes on it before App Review, bring it to App Store Launch Club. Members share their builds for feedback, and the [curriculum](/curriculum) covers the full path from first build to first users. Join at applaunchclub.co for $9 a month.

Free app-building tips, straight to your inbox

Short, practical drops on app ideas, validating fast, store listings, and passing app review. No spam, unsubscribe anytime.

Frequently asked questions

How do I copy text to the clipboard in Expo?

Install expo-clipboard, import it with import * as Clipboard from 'expo-clipboard', and call await Clipboard.setStringAsync(text) from a button press. Show a short confirmation so the user knows it worked.

Does expo-clipboard work in Expo Go?

Yes. The expo-clipboard reference lists it as included in Expo Go, and it works on Android, iOS and web.

Why does my Expo app show an Allow Paste prompt on iOS?

In iOS 16 and later, reading the clipboard from code asks the user for approval. Only read the clipboard when the user taps a paste control, or use ClipboardPasteButton, which pastes without the prompt.

Why does Clipboard.getStringAsync return an empty string?

Either the clipboard is empty or, on iOS 16 and later, the user denied paste access. The expo-clipboard reference says there is no way to tell the two apart, so treat an empty string as nothing to paste.

Can I copy an image to the clipboard in Expo?

Yes. Call Clipboard.setImageAsync with a base64 string without the MIME prefix, for example from expo-image-picker with base64: true. Read images back with getImageAsync({ format: 'png' }).

Should I use the Clipboard API from react-native?

No. React Native's docs mark its Clipboard API as removed. In an Expo app, use expo-clipboard instead.

How do I stop copied passwords showing in keyboard previews on Android?

Pass android: { isSensitive: true } to setStringAsync or setImageAsync. On Android 13 and later this hides the clipboard preview overlay and signals keyboards not to show the content.

Last reviewed by David on October 20, 2026

David

Written by

David

Founder and app builder

Keep reading

ExpoClaude Code

How to Add Notification Actions to Your Expo App

To add notification actions to an Expo app, register a category with Notifications.setNotificationCategoryAsync, give it action buttons (and optionally a text reply), set categoryIdentifier on the notification, then read response.actionIdentifier in a response listener. Here is every action option, how to handle taps when the app was closed, the Android and iOS differences, and a Claude Code prompt that wires it all up.

David 8 min
Read article
ExpoClaude Code

How to Schedule Local Notifications in Your Expo App

To schedule local notifications in an Expo app, install expo-notifications, set a notification handler, ask for permission, create an Android channel, then call scheduleNotificationAsync with your content and a trigger like DAILY, WEEKLY or DATE. Here is every trigger type, how to cancel and list what is scheduled, why Android reminders arrive late, and a Claude Code prompt that builds the whole reminder flow.

David 8 min
Read article

Ready to build it yourself?

Join App Store Launch Club, the #1 community for building and launching apps, for $9/month.

← Back to the blog