Code Reference

Linking (Expo)

Expo · Reference cheat sheet

Linking (Expo)

Expo · Reference cheat sheet


📋 Overview

Expo linking builds on RN Linking with expo-linking helpers and Expo Router path integration. Set scheme in app config; use universal links / app links for https. Create URLs with Linking.createURL for consistent env behavior.

🔧 Core concepts

PieceRole
schemeCustom URL scheme in config
createURLBuild deep link for current env
parseParse path/query
Expo RouterFile paths map to URLs
Universal linksassociatedDomains / intent filters

Dev client / Go vs production URLs differ—createURL helps.

💡 Examples

import * as Linking from "expo-linking";
import { useEffect } from "react";
import { router } from "expo-router";

const prefix = Linking.createURL("/");

export function useDeepLinks() {
  useEffect(() => {
    function handle(url: string) {
      const { path, queryParams } = Linking.parse(url);
      if (path?.startsWith("post/")) {
        router.push(`/post/${queryParams?.id ?? ""}`);
      }
    }
    Linking.getInitialURL().then((url) => url && handle(url));
    const sub = Linking.addEventListener("url", ({ url }) => handle(url));
    return () => sub.remove();
  }, []);
}

export function shareLink(id: string) {
  return Linking.createURL(`/post/${id}`);
}
{
  "expo": {
    "scheme": "myapp",
    "ios": { "associatedDomains": ["applinks:example.com"] },
    "android": {
      "intentFilters": [
        {
          "action": "VIEW",
          "autoVerify": true,
          "data": [{ "scheme": "https", "host": "example.com", "pathPrefix": "/" }],
          "category": ["BROWSABLE", "DEFAULT"]
        }
      ]
    }
  }
}

⚠️ Pitfalls

  • Hardcoding myapp:// without createURL (breaks in Expo Go).
  • Missing AASA / assetlinks verification for https links.
  • Not testing cold start (getInitialURL).
  • Scheme typos between config and marketing links.

On this page