Next.js New Link

verified codemod icon

This codemod safely removes <a> from Link components imported from the next/link module or adds the legacyBehavior prop on the component level.

Next.js
jscodeshift
Estimated time saving
5 minutes/occurrence
Change mode
Autonomous
Applicability criteria

Next.js version higher or equal to 13

Made by
Vercel
Vercel

Usage →

Codemod CLI:

intalling vs code extension tooltip icon
codemod next/13/new-link
copy CLI command icon

Codemod VS Code extension:

intalling vs code extension tooltip icon
vs code logo
Run in VS Code

Description

Safely removes <a> from Link components imported from the next/link module or adds the legacyBehavior prop on the component level.

Example

Before

export default function Component() {
	return (
		<Link href="/a">
			<a>Anchor</a>
		</Link>
	);
}

After

export default function Component() {
	return <Link href="/a">Anchor</Link>;
}

Links for more info