Links using ~ do not respect `base`
Open
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 7.9k
- Forks
- 190
- Avg merge
- 12h 50m
- Merged PRs (30d)
- 3
Description
Example:
import { Router, Route, Link } from "wouter";
function ScheduleOverview() {
return (
<div>
<h1>Schedule Overview</h1>
<Link href="/2026-02-11">Go to Feb 11</Link>
</div>
);
}
function ScheduleDetail({ date }) {
return (
<div>
<h1>Schedule for {date}</h1>
{/* Expected: navigates to /app/schedule */}
{/* Actual: navigates to /schedule (missing /app base) */}
<Link href="~/schedule">Back to Overview</Link>
</div>
);
}
function App() {
return (
<Router base="/app">
<Route path="/schedule" nest>
<Route path="/">
<ScheduleOverview />
</Route>
<Route path="/:date">
{({ date }) => <ScheduleDetail date={date} />}
</Route>
</Route>
</Router>
);
}
- Navigate to /app/schedule/2026-02-11
- Click "Back to Overview" link
- Expected: navigates to /app/schedule
- Actual: navigates to /schedule (base path /app is not applied)
I understand from the docs (under Router) that the ~ is an escape hatch to navigate to an absolute path since /-prefixed urls are relative to the parent route, but is there a way to route relative to the base?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the example with Router base="/app", nested routes, and a Link using href="~/schedule"; inspect how Router and Link resolve base paths and escaped URLs. Done means the link reaches the expected base-prefixed route without breaking the documented absolute-path behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100