Smart App Link
All posts

How to add a "Share this app" button in Expo and React Native

, 3 min read

Word of mouth is still one of the best ways to grow an app. A "Share this app" button makes it easy: one tap, and your user can send your app to a friend over WhatsApp, iMessage or anywhere else.

Building the button takes a few lines of code. Choosing the link it shares is where most apps get it wrong. This guide covers both.

The mistake most share buttons make

The obvious approach is to share the store link for the phone the user is holding:

// Don't do this
const storeUrl = Platform.OS === "ios" ? APP_STORE_URL : PLAY_STORE_URL;

It looks right, but think about who opens the link. If someone on Android shares your app with a friend who has an iPhone, the friend gets a Google Play link. It opens a web page they can't install from, and you lose the install.

What matters is the device of the person receiving the link, not the person sending it. And when you write the code, you can't know which device that will be.

Want the short way?

Smart App Link gives you one link that opens the App Store on iPhone and Google Play on Android. Free, no card.

Create free link

Use one link that works on every phone

The fix is to share a single link that decides where to go when it's opened. A smart app link does this: iPhone users go to the App Store, Android users go to Google Play, and desktop users go to your website.

To make one:

  1. Find your two store links. Your Google Play link uses the android.package from your app.json: https://play.google.com/store/apps/details?id=com.yourcompany.app. Your App Store link uses the numeric Apple ID from App Store Connect (App Information): https://apps.apple.com/app/id1234567890. There's more detail in how to find your store links.
  2. Create a free smart link with both store links.
  3. You'll get a link like https://smartapplink.app/r/yourapp. That's the one your app shares.

A bonus: because the link isn't a store URL, you can change where it points later (a new website, a moved listing) without shipping an app update.

Add the share button

React Native includes a Share API that opens the phone's native share sheet. It works in Expo out of the box. There's nothing to install, and you don't need a development build. (expo-sharing is a different library, made for sharing files, so you don't need it here.)

import { Platform, Pressable, Share, Text } from "react-native";

const APP_LINK = "https://smartapplink.app/r/yourapp";
const MESSAGE = "I've been using YourApp and thought you'd like it:";

export async function shareApp() {
  try {
    await Share.share(
      Platform.OS === "ios"
        ? { message: MESSAGE, url: APP_LINK } // iOS shows the link as a rich preview
        : { message: `${MESSAGE} ${APP_LINK}` } // Android only sends `message`
    );
  } catch {
    // The share sheet failed to open; nothing else to do.
  }
}

export function ShareAppButton() {
  return (
    <Pressable onPress={shareApp}>
      <Text>Share this app</Text>
    </Pressable>
  );
}

There's one platform difference to handle. On iOS, Share.share accepts a separate url, which apps like iMessage turn into a link preview. Android ignores url and only sends message, so the link has to be part of the message text there.

Where to put the button

A share button only works if people see it at the right moment. Good places:

  • After a success moment, such as finishing a workout, completing an order, or reaching a streak. People share when they feel good about the app.
  • In the settings or profile screen, as a "Tell a friend" row. It's low-key, but people look for it there.
  • On invite flows, if your app is better with friends.

Avoid showing a share prompt on first launch, before the user knows whether they like your app.

See how many people your users bring in

To check that the button actually works, add a source to the link so its traffic shows up separately in your stats:

const APP_LINK = "https://smartapplink.app/r/yourapp?utm_source=in_app_share";

Every smart link counts its clicks and shows how many came from iPhone, Android and desktop. On the Pro plan, analytics also break clicks down by source, so you can see exactly how many people your share button sends to the stores compared with your website or social posts.

Use the same link everywhere else

The link you put in your share button works anywhere you'd otherwise post two store badges: your website, your Instagram bio, email signatures, and QR codes on posters or packaging. You can make a QR code for it for free.

Create your free smart link. It takes about a minute, and the free plan covers your first 3 links.