Skip to content

router.push with --base path leads to duplicated base path in navigation (v52.16.0+) #2656

Description

@iiicon

Environment:

  • Slidev version: 52.16.0 (introduced in v52.16.0, worked correctly in v52.15.2)
  • Browser: All

Describe the bug:

When building Slidev slides with --base /talks/<folder>/ and using $slidev.nav.next or $slidev.nav.go(), the router navigation results in duplicated base path in the URL.

Actual behavior:

  • Initial URL: /talks/2026-06-30-xihuan/
  • Click nav.next → /talks/2026-06-30-xihuan/talks/2026-06-30-xihuan/2 (WRONG - base duplicated)
  • Expected: /talks/2026-06-30-xihuan/2 (CORRECT)

Root cause:

In v52.16.0, getSlidePath (packages/client/logic/slides.ts) was changed to include import.meta.env.BASE_URL:

// v52.15.2 and earlier:
return exporting ? `/export/${no}` : presenter ? `/presenter/${no}` : `/${no}`

// v52.16.0+:
return exporting ? `/export/${no}` : presenter ? `/presenter/${no}` : `${import.meta.env.BASE_URL}${no}`

Then in useNav.ts, the go() method does:

await router.push({
  path: getSlidePath(...), // already includes BASE_URL
  ...
})

But createWebHistory(BASE_URL) in setup/main.ts treats the path as relative and prepends the base again, causing duplication.

Reproduction:

pnpm exec slidev build --base /talks/2026-06-30-xihuan/ --out dist
# Serve with any static file server
# Navigate via $slidev.nav.next → URL will have duplicated base

Workarounds:

  • Downgrade to v52.15.2 (last known working version)
  • Use keyboard shortcuts (Space/Arrow) instead of $slidev.nav.next

Expected fix:
getSlidePath should return path segments without the base prefix, letting createWebHistory handle the base path automatically (like it does for createMemoryHistory and other router implementations).

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions