molefrog / molefrog/wouter

Links using ~ do not respect `base`

Open
#558 1 comment 0 reactions 0 assignees View on GitHub

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>
  );
}
  1. Navigate to /app/schedule/2026-02-11
  2. Click "Back to Overview" link
  3. Expected: navigates to /app/schedule
  4. 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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.