rsnext/errors/app-dir-dynamic-href.md
Hannes Bornö 0f195f0270
App directory next/link dynamic href dev error (#43074)
Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
Fixes https://github.com/vercel/next.js/issues/42715
2022-11-25 15:03:00 +01:00

689 B

Dynamic href is not supported in the /app directory

Why This Error Occurred

You have tried to use a dynamic href with next/link in the app directory. This is not supported as the new client-side router no longer uses a mapping of dynamic routes -> url, instead it always leverages the url.

Possible Ways to Fix It

Before

<Link
  href={{
    pathname: '/route/[slug]',
    query: { slug: '1' },
  }}
>
  link
</Link>

Or

<Link href="/route/[slug]?slug=1">link</Link>

After

<Link href="/route/1">link</Link>

next/link documentation