# Next.js: Error: Failed prop type: The prop `href` expects a `string` or `object` in `<Link>`, but got `undefined` instead

**Code:** `Failed prop type: The prop href expects a string or object in <Link>` · **Category:** Next.js · **Seen on:** Next.js, React

`<Link href>` received `undefined` (or another invalid value), so Next.js can't build the link.

## 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.slug` vs `item.path`)
- Data not loaded when rendering
- Empty string href in list items
- Passing a number/boolean

## Quick fix

1. Guard: `{item.url && <Link href={item.url}>…</Link>}`
2. Verify the field name in the data
3. Use `href={{ pathname: "/p/[id]", query: { id } }}` for objects

## Detailed fix by platform

### Next.js

1. `<Link href={post.slug ? `/blog/${post.slug}` : "/blog"}>{post.title}</Link>`

## How to diagnose

1. **Value** — undefined?
2. **Field** — Correct name?
3. **Timing** — Loaded?

---
Source: [WhatIsMyError](https://whatismyerror.com/errors/nextjs/link-invalid-href-prop)
