EasyCord LogoDocs
Plugin EcosystemSystem & OS

Deep Links

Handle universal links and custom URL schemes.

The DeepLinks plugin captures application launch URLs and custom URL scheme invocations, routing them into your React application seamlessly.

Installation

npm install @easycord/deeplinks

API Reference

addListener('appUrlOpen', callback)

Fired whenever the application is opened via a deep link.

import { DeepLinks } from '@easycord/deeplinks';
import { useEffect } from 'react';
import { useRouter } from 'next/router';

export function DeepLinkProvider({ children }: { children: React.ReactNode }) {
  const router = useRouter();

  useEffect(() => {
    const listener = DeepLinks.addListener('appUrlOpen', (event) => {
      // E.g. myapp://path/to/page
      const url = new URL(event.url);
      if (url.pathname) {
        router.push(url.pathname);
      }
    });

    return () => listener.remove();
  }, [router]);

  return <>{children}</>;
}