Skip to content

Unexpected next/link Behavior: <Link> with same-origin absolute URL triggers full page reload #335

@sindhukhrisna

Description

@sindhukhrisna

Summary

Using an absolute URL with the same origin in <Link> causes a full page reload instead of client-side navigation.
I'm not sure if this is intended or a missed edge case.

Example:

<Link href="/path">works</Link>
<Link href="https://example.com/path">reloads page</Link>

When the domain matches the current origin, the router should treat it as an internal route and perform client-side navigation.

Expected behavior

Navigation should behave the same for both:

<Link href="/path" />
<Link href="https://example.com/path" />

If the URL origin matches window.location.origin, the router should treat it as an internal navigation and preserve layouts (SPA behavior).

This is how Next.js currently behaves.

Actual behavior

Using an absolute URL with the same domain causes a full page reload, which resets layouts and loses client state.

Steps to reproduce

  1. Create a Vinext app
  2. Add two routes (/ and /path)
  3. Add the following links on /:
<Link href="/path">Relative link</Link>
<Link href="https://example.com/path">Absolute same-origin link</Link>
  1. Click both links

Result:

  • Relative link → client-side navigation
  • Absolute link → full page reload

Environment

  • Vinext: 0.0.24
  • Node: 24.9.0
  • Browser: Chrome

Possible cause

It seems the router only treats URLs starting with / as internal routes. Absolute URLs may not be normalized before routing.

Next.js normalizes same-origin URLs and converts them internally to relative paths before routing.

A similar approach might resolve this behavior.

Workaround

Use relative URLs for internal navigation:

<Link href="/path" />

However, this can be inconvenient or breaks current nextjs codebase when URLs are generated dynamically or include canonical/base URLs.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions