Skip to main content

Lesson 7 of 10

Deep Linking - Universal Links & App Links

Deep links open specific screens in your app from outside - a notification, a website link, a QR code. Universal Links (iOS) and App Links (Android) are the verified versions that don't show a disambiguation dialog.

25 minBy Priygop Editorial TeamUpdated 2026Peer Reviewed & Verified

React Navigation Linking Config

React Navigation Linking Config
import { LinkingOptions } from '@react-navigation/native';

const linking: LinkingOptions<RootParamList> = {
  prefixes: [
    'myapp://',                                // Custom URL scheme
    'https://myapp.com',                       // Universal Link / App Link
    'https://link.myapp.com',                 // Branch / Firebase Dynamic Links
  ],
  config: {
    screens: {
      Main: {
        screens: {
          Home: {
            screens: {
              HomeScreen: 'home',               // myapp://home → HomeScreen
              ProductDetail: 'product/:productId', // myapp://product/123
            },
          },
          Profile: {
            screens: {
              ProfileScreen: 'user/:userId',    // myapp://user/abc
            },
          },
        },
      },
      Auth: 'auth',
    },
  },
  // Parse custom URL params
  getStateFromPath(path, options) {
    // Custom parsing, or use default
    return getStateFromPath(path, options);
  },
};

// Test deep links
// iOS Simulator: xcrun simctl openurl booted "myapp://product/123"
// Android Emulator: adb shell am start -W -a android.intent.action.VIEW -d "myapp://product/123"

// ---- Handling links while app is already open ----
import { Linking } from 'react-native';
import { useEffect } from 'react';

function App() {
  useEffect(() => {
    // App was opened by a link while already running
    const subscription = Linking.addEventListener('url', ({ url }) => {
      console.log('Deep link received:', url);
    });
    return () => subscription.remove();
  }, []);
}

Tip

Tip

Practice Deep Linking Universal Links App Links in small, isolated examples before integrating into larger projects. Breaking concepts into small experiments builds genuine understanding faster than reading alone.

Diagram
Loading diagram…

Resolving incoming custom scheme URLs and universal links directly to screens

Practice Task

Note

Practice Task - (1) Write a working example of Deep Linking Universal Links App Links from scratch without looking at notes. (2) Modify it to handle an edge case (empty input, null value, or error state). (3) Share your solution in the Priygop community for feedback.

Quick Quiz

Common Mistake

Warning

A common mistake with Deep Linking Universal Links App Links is skipping edge case testing - empty inputs, null values, and unexpected data types. Always validate boundary conditions to write robust, production-ready react native code.

Topics in This Module

0/10 done