Skip to content

Instantly share code, notes, and snippets.

View xesrevinu's full-sized avatar
🎯
Focusing

Ray xesrevinu

🎯
Focusing
View GitHub Profile
// file: hooks/useLinkHandler.ts
// Turn all HTML <a> elements into client side router links, no special framework-specific <Link> component necessary!
// Example using the Next.js App Router.
import { useRouter } from 'next/navigation';
import { useEffect } from 'react';
export function useLinkHandler(handle: (href: string) => void) {
useEffect(() => {
const onClick = (e: MouseEvent) => {