Skip to content

data-sveltekit-preload-data="hover" fails after client-side navigation with dynamic hrefs #15171

@emincangencer

Description

@emincangencer

Describe the bug

The data-sveltekit-preload-data="hover" attribute works on initial page load but stops triggering prefetch after client-side navigation when link hrefs change dynamically.

Expected behavior
Prefetch should work consistently regardless of navigation history, as hrefs are valid and component re-renders correctly.
Actual behavior
Prefetch only works on initial page load. After navigation, no __data.json requests occur on hover despite hrefs being correct.

Reproduction

  1. Create a component with navigation links that update hrefs after navigation
  2. Set data-sveltekit-preload-data="hover" globally or explicitly on links
  3. Load page and hover over links → prefetch works (GET __data.json)
  4. Click link to navigate client-side
  5. On new page, hover over the same link with updated hrefs → no prefetch occurs
  6. Workaround: Manual preloadData() on mouseenter works reliably

A minimal codebase reproduction:

  1. Go item 2. Open network tab.
  2. Hover on next. It will fetch __data.json.
  3. Click on next.
  4. Hover on next. It won't fetch.
    1. Hover on previous, and then next. It will fetch. 2) Or just click next and it will fetch but not upon hover.

https://stackblitz.com/edit/sveltejs-kit-template-default-hpzyj4p1?file=src%2Froutes%2Fitem%2F%5Bid%5D%2F%2Bpage.svelte

Logs

System Info

System:
    OS: Linux 6.18 Arch Linux
    CPU: (16) x64 AMD Ryzen 7 7730U with Radeon Graphics
    Memory: 3.82 GB / 14.96 GB
    Container: Yes
    Shell: 5.3.9 - /usr/bin/bash
  Binaries:
    Node: 22.20.0 - /home/emincan/.config/nvm/versions/node/v22.20.0/bin/node
    npm: 10.9.3 - /home/emincan/.config/nvm/versions/node/v22.20.0/bin/npm
    pnpm: 10.20.0 - /home/emincan/.local/share/pnpm/pnpm
    bun: 1.3.0 - /home/emincan/.bun/bin/bun
  Browsers:
    Chromium: 143.0.7499.192
  npmPackages:
    @sveltejs/adapter-cloudflare: ^7.2.4 => 7.2.4
    @sveltejs/kit: ^2.49.4 => 2.49.4
    @sveltejs/vite-plugin-svelte: ^6.2.4 => 6.2.4
    svelte: ^5.46.3 => 5.46.3
    vite: ^7.3.1 => 7.3.1

Severity

annoyance

Additional Information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions