From 51e01ec1429900e02fb43c86ea84fd4e091f9caf Mon Sep 17 00:00:00 2001 From: Valerio Ageno Date: Fri, 16 Aug 2024 11:21:18 +0200 Subject: [PATCH] feat: add link support to hash --- packages/router/src/components/Link.tsx | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/router/src/components/Link.tsx b/packages/router/src/components/Link.tsx index 530d0def..a5a6b6e1 100644 --- a/packages/router/src/components/Link.tsx +++ b/packages/router/src/components/Link.tsx @@ -24,6 +24,12 @@ export default function Link( const handleTransition = (e: MouseEvent): void => { e.preventDefault() props.onClick?.(e) + + if (props.href?.startsWith('#')) { + window.location.hash = props.href + return + } + router.push(props.href || '') }