- Remove external next-view-transitions dependency - Use Next.js 16 native navigation and Safari 18+ native View Transition API - Add ViewTransitionProvider for minimal wrapping with Safari 18+ detection - Updated all Link imports from external package to next/link - Removed link-wrapper.tsx and view-transitions-wrapper.tsx This resolves Safari compatibility issues while maintaining transitions on modern browsers.
21 lines
801 B
TypeScript
21 lines
801 B
TypeScript
'use client';
|
|
|
|
import { useState, useEffect, ReactNode } from 'react';
|
|
import Link from 'next/link';
|
|
|
|
export function NativeLink({ href, children, ...props }: { href: string; children: ReactNode; [key: string]: any }) {
|
|
const [isSafari18, setIsSafari18] = useState(false);
|
|
|
|
useEffect(() => {
|
|
const isSafari = typeof navigator !== 'undefined' && navigator.userAgent.includes('safari') && !navigator.userAgent.includes('chrome') && !navigator.userAgent.includes('firefox');
|
|
const hasNativeTransitions = typeof document !== 'undefined' && typeof document.startViewTransition === 'function';
|
|
setIsSafari18(isSafari && hasNativeTransitions);
|
|
}, []);
|
|
|
|
if (isSafari18) {
|
|
return <a href={href} {...props}>{children}</a>;
|
|
}
|
|
|
|
return <Link href={href} {...props}>{children}</Link>;
|
|
}
|