nyuchimzizi
Mzizi — an open-architecture project of the Bundu Foundation, operated and developed by Nyuchi. Built on the Five African Minerals palette.
Built by Nyuchi Africav4.0.39
Universal link and deep link routing handler. Maps external URLs, push notification taps, and share links to in-app routes. Handles: mukoko.com/{path}, mini-app deep links, push notification payloads, NFC/QR scan results.
View the full component source code below.
"use client"
import * as React from "react"
import { useNyuchiHarness } from "@/lib/harness"
interface DeepLinkRoute {
pattern: string | RegExp
handler: (params: Record<string, string>) => void
}
interface NyuchiDeepLinkHandlerProps {
routes: DeepLinkRoute[]
onUnmatched?: (url: string) => void
children: React.ReactNode
}
export function NyuchiDeepLinkHandler({ routes, onUnmatched, children }: NyuchiDeepLinkHandlerProps) {
const { log } = useNyuchiHarness("deep-link-handler")
const resolve = React.useCallback((url: string) => {
log.info(`deep_link: ${url}`)
for (const route of routes) {
if (typeof route.pattern === "string") {
const regex = new RegExp("^" + route.pattern.replace(/:(\w+)/g, "(?<$1>[^/]+)") + "$")
const match = url.match(regex)
if (match?.groups) { route.handler(match.groups); return }
} else {
const match = url.match(route.pattern)
if (match?.groups) { route.handler(match.groups); return }
}
}
log.warn(`deep_link_unmatched: ${url}`)
onUnmatched?.(url)
}, [routes, onUnmatched, log])
// Listen for popstate and custom deep-link events
React.useEffect(() => {
function onEvent(e: CustomEvent) { resolve(e.detail?.url || "") }
window.addEventListener("nyuchi:deep-link" as any, onEvent as any)
return () => window.removeEventListener("nyuchi:deep-link" as any, onEvent as any)
}, [resolve])
// Check initial URL
React.useEffect(() => {
const path = window.location.pathname + window.location.search
if (path && path !== "/") resolve(path)
}, [resolve])
return <div data-slot="nyuchi-deep-link-handler" data-portal="https://design.nyuchi.com/components/nyuchi-deep-link-handler">{children}</div>
}
export type { DeepLinkRoute, NyuchiDeepLinkHandlerProps }
npx shadcn@latest add https://mzizi.dev/api/v1/ui/nyuchi-deep-link-handlerFetch this component's metadata and source code from the registry API.
/api/v1/ui/nyuchi-deep-link-handler