#2306·waku

router/client-core: expose action-origin handling so non-History bindings can use unstable_rerenderRoute()

Author: dai-shiCreated Sep 18, 2026Updated Sep 18, 2026

Summary

unstable_rerenderRoute() with no arguments (#2300) only works with the History binding (waku/router/client). A binding built on waku/router/client-core (the use case #2274 extracted it for, e.g. waku-navigation) can't support it, because what it needs isn't exported from client-core.

Reproduction

waku 1.0.0-rc.1 with a client-core binding (waku-navigation, Navigation API):

typescript
'use server';
import { unstable_rerenderRoute } from 'waku/router/server';

export async function save() {
  // ...mutation
  unstable_rerenderRoute();
}

Calling save() from a client component makes the server throw Error: The route this action came from is unknown (request-handler.tsx:122), and the client gets a 500. unstable_rerenderRoute('/path') works.

Cause

The server gets the action's origin route from the X-Waku-Action-Location request header (parseActionOrigin, request-handler.tsx:42). Only the History binding sends it, through a Root RSC enhancer in router/client-utils/navigation.ts (L461–510, ACTION_ENHANCER_ORDER = 100). That enhancer also handles the response:

  • drops an IS_ORIGIN response if the user has moved to another route, or a navigation to another route is pending
  • strips the IS_ORIGIN key before merging
  • commits any route change the action returned

ACTION_LOCATION_HEADER and IS_ORIGIN_ID (route-path.ts:101,103) aren't exported from waku/router/client-core. A client-core binding would have to hardcode 'X-Waku-Action-Location' and 'IS_ORIGIN', the kind of internal detail the custom-router guide asks not to reproduce.

Proposal

Move the action-origin enhancer into client-core as a hook both bindings use, for example:

typescript
useActionOrigin_UNSTABLE({
  getSettledRoute: () => RouteProps,
  getPendingRoute: () => Pick<RouteProps, 'path' | 'query'> | undefined,
  onRouteElements: (elements) => void, // the binding commits a route change
});

A smaller alternative is to export unstable_ACTION_LOCATION_HEADER and unstable_IS_ORIGIN_ID from client-core and document the enhancer contract next to Unstable_RouterHost. Then every binding has to re-implement the staleness rules above, though; a shared hook keeps them in one place.

Related: #2302 is in the same enhancer code; moving it into client-core would fix that once for both bindings. The nav-api-spike fixture has no server-action coverage; a rerenderRoute() case there would cover this.