Next.js: Error: Failed prop type: The prop `href` expects a `string` or `object` in `<Link>`, but got `undefined` instead
<Link href> received undefined (or another invalid value), so Next.js can't build the link.
Failed prop type: The prop `href` expects a `string` or `object` in `<Link>`, but got `undefined` insteadThe prop href expects a string or object in <Link>, but got undefinedError: Failed prop type: The prop `href` expects a `string` or `object`Invalid href passed to next/router Meaning
The href variable is undefined at render: missing data, a wrong field name, or an async value not loaded yet. Provide a fallback (href={item.url ?? "#"}) or render the link only when data exists. For objects: { pathname, query }.
Common causes
- href from undefined/null data
- Wrong property name (
item.slugvsitem.path) - Data not loaded when rendering
- Empty string href in list items
- Passing a number/boolean
⚡ Quick fix
- Guard:
{item.url && <Link href={item.url}>…</Link>} - Verify the field name in the data
- Use
href={{ pathname: "/p/[id]", query: { id } }}for objects
Detailed fix by platform
Next.js
<Link href={post.slug ?/blog/${post.slug}: "/blog"}>{post.title}</Link>
How to diagnose
- Value — undefined?
- Field — Correct name?
- Timing — Loaded?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- [Vue warn]: Invalid prop: type check failed Vue: [Vue warn]: Invalid prop: type check failed for prop "count". Expected Number with value 5, got String with value "5"
- [Vue warn]: Missing required prop Vue: [Vue warn]: Missing required prop: "title"
- [Vue warn]: Set operation on key failed: target is readonly Vue: [Vue warn]: Set operation on key "name" failed: target is readonly.
Most viewed in Next.js
- NEXT_REDIRECT Next.js: Error: NEXT_REDIRECT (redirect() inside try/catch)
- server-only Next.js: You're importing a component that needs "server-only". That only works in a Server Component
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Other ways to find it
Where this error sits
Origin: On your device. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 5 Nov 2026