import { Link, useCanGoBack, useRouter } from "@tanstack/react-router";
import type { LinkProps } from "@tanstack/react-router";
import { ArrowLeft } from "lucide-react";
// A "Back to ..." link that uses browser history when available,
// falling back to a typed Link destination otherwise.
// This preserves scroll position and filter state when navigating
// back from a detail page to a list.
export function BackLink({
children,
...fallbackProps
}: LinkProps & { children: React.ReactNode }) {
const canGoBack = useCanGoBack();
const router = useRouter();
if (canGoBack) {
return (
);
}
return (
{children}
);
}