Files
archived-next-auth/apps/examples/nextjs/components/custom-link.tsx
Balázs Orbán 65aa467c0e feat(nextjs): introduce next-auth v5 (#7443)
Next.js 13.4 [is out](https://nextjs.org/blog/next-13-4).

For discussing project-related issues, please use https://github.com/nextauthjs/next-auth/discussions/8487

The new version of NextAuth.js is based on `@auth/core`.

If you want to test it out, you can do so already, installing `next-auth@experimental`:

- **Documentation**: https://authjs.dev/reference/nextjs
- **Migration guide**: https://authjs.dev/guides/upgrade-to-v5

BREAKING CHANGE:
Follow the [migration guide](https://authjs.dev/guides/upgrade-to-v5)
2023-10-23 17:35:30 -07:00

41 lines
839 B
TypeScript

import { cn } from "@/lib/utils"
import { ExternalLink } from "lucide-react"
import Link from "next/link"
interface CustomLinkProps extends React.LinkHTMLAttributes<HTMLAnchorElement> {
href: string
}
const CustomLink = ({
href,
children,
className,
...rest
}: CustomLinkProps) => {
const isInternalLink = href.startsWith("/")
const isAnchorLink = href.startsWith("#")
if (isInternalLink || isAnchorLink) {
return (
<Link href={href} className={className} {...rest}>
{children}
</Link>
)
}
return (
<Link
href={href}
target="_blank"
rel="noopener noreferrer"
className={cn("items-center underline", className)}
{...rest}
>
{children}
<ExternalLink className=" ml-0.5 h-4 w-4 inline-block" />
</Link>
)
}
export default CustomLink