Closed coderfin closed 1 month ago
I have a workaround but it would be nice not to have to create a new component to import.
import { Link as I18nLink } from '@/lib/i18n'
import type { Route } from 'next'
export default function Link<T extends string>({
href,
children,
...rest
}: {
href: Route<T> | URL
} & React.ComponentPropsWithoutRef<typeof I18nLink>) {
return (
<I18nLink href={href} {...rest}>
{children}
</I18nLink>
)
}
+1 This should absolutely be supported
I've been able to get it to work by using typeof import("next/link").default
as a type-annotation internally instead of inlining the type. However, the typescript compiler insists on inlining it anyways, I still need to find a workaround there.
As a NextJS dev using Paraglide-Next it would be nice to have support for statically typed links.
NextJS has a
typedRoutes
feature that can be enabled to supportstatically typed links
. As stated in the NextJS documentation this helps to:https://nextjs.org/docs/app/building-your-application/configuring/typescript#statically-typed-links https://nextjs.org/docs/app/api-reference/next-config-js/typedRoutes
The href type is currently:
The NextJS docs suggest: