React context provider that registers and dispatches Expo deep-link handlers by path, enabling screens to handle incoming URLs. Reuse for centralized deep-link routing in Expo apps.
// Source: https://github.com/polarsource/polar | License: Apache-2.0 | Copyright You must retain, in the Source form of any Derivative Works
// Provided via justclaw.it.com; keep this notice with the code.
import * as Linking from 'expo-linking'
import { useRouter } from 'expo-router'
import {
createContext,
useCallback,
useContext,
useEffect,
useRef,
} from 'react'
type DeepLinkHandler = (url: URL) => boolean | void
interface DeepLinkContextValue {
registerHandler: (path: string, handler: DeepLinkHandler) => () => void
}
const DeepLinkContext = createContext<DeepLinkContextValue>({
registerHandler: () => () => {},
})
export const useDeepLinks = () => useContext(DeepLinkContext)
export default function DeepLinkProvider({
children,
}: {
children: React.ReactNode
}) {
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key