Intent to Ship: Navigation API: add post-commit handler from precommit

91 views
Skip to first unread message

Chromestatus

unread,
Feb 3, 2026, 7:36:06 AM (4 days ago) Feb 3
to blin...@chromium.org, nrose...@chromium.org
Contact emails
nrose...@chromium.org

Explainer
https://github.com/WICG/navigation-api/pull/294

Specification
https://html.spec.whatwg.org/#dom-navigationprecommitcontroller-addhandler

Summary
Currently when intercepting navigations with the `navigate` event, precommitHandlers and post-commit ordinary handlers are passed separately. This works well when there is only one or the other, but can be a bit clunky when the flow includes a precommitHandler that leads to a post-commit handler. This addition is a small ergonomic improvement that enables registering a post-commit handler while invoking a precommit handler.

Blink component
Blink>DOM

Web Feature ID
navigation

Motivation
This is a small ergonomic fix to the API enabling a bit more flexibility.

Initial public proposal
https://github.com/whatwg/html/issues/11956

TAG review
No information provided

TAG review status
Pending

Risks


Interoperability and Compatibility
None, new API

Gecko: No signal

WebKit: No signal

Web developers: Positive This was initially raised by Jake Archibald when at Shopify.

Other signals:

WebView application risks

Does this intent deprecate or change behavior of existing APIs, such that it has potentially high risk for Android WebView-based applications?

No information provided


Debuggability
No information provided

Will this feature be supported on all six Blink platforms (Windows, Mac, Linux, ChromeOS, Android, and Android WebView)?
Yes

Is this feature fully tested by web-platform-tests?
Yes


Flag name on about://flags
No information provided

Finch feature name
NavigateEventAddHandlerOnPrecommit

Rollout plan
Will ship enabled for all users

Requires code in //chrome?
False

Tracking bug
https://issues.chromium.org/issues/465487215

Estimated milestones
Shipping on desktop147
Shipping on Android147
Shipping on WebView147


Anticipated spec changes

Open questions about a feature may be a source of future web compat or interop issues. Please list open issues (e.g. links to known github issues in the project for the feature specification) whose resolution may introduce web compat/interop risk (e.g., changing to naming or structure of the API in a non-backward-compatible way).

No information provided

Link to entry on the Chrome Platform Status
https://chromestatus.com/feature/5176907844943872?gate=6492610946531328

This intent message was generated by Chrome Platform Status.

Yoav Weiss (@Shopify)

unread,
Feb 3, 2026, 11:47:09 PM (4 days ago) Feb 3
to blink-dev, Chromestatus, Noam Rosenthal
On Tuesday, February 3, 2026 at 1:36:06 PM UTC+1 Chromestatus wrote:
Contact emails
nrose...@chromium.org

Explainer
https://github.com/WICG/navigation-api/pull/294

A bit more details would be useful here.
Even reading through https://github.com/WICG/navigation-api?tab=readme-ov-file#precommit-handlers, the role of post-commit handlers, nor how does one define them today is not clear.

I *think* I have a vague idea, so let me try to take a stab and let me know if I got it right.
Currently a developer that wants to add a post-commit handler (or simply a `handler` in the current API) to e.g. send analytics that a navigation has happened, can do that using
```
navigation.addEventListener("navigate", e => {
   if (e.canIntercept) {
    const handler = sendAnalytics(e);
    e.intercept({ handler });
  }
});
```

When they want to do something pre-commit (e.g. cancel the navigation if the target URL doesn't lead to a cat video), they can do something like
```
navigation.addEventListener("navigate", e => {
   if (e.canIntercept) {
    const precommitHandler = verifyCatVideo(controller);
    e.intercept({ precommitHandler });
  }
});
```
They can even add both.

But when developers today want to add a post-commit (or "regular") handler as a result of some handler in the pre-commit, they have no way of doing that.

This proposal is to add an `addHandler` method to the precommit controller, that would enable to add such post-commit handlers.

Is that roughly accurate?

If so, what would be an example use-case of wanting to add a post-commit handler as a result of pre-commit logic? What information does the pre-commit handler have that a post-commit logic doesn't?

Noam Rosenthal

unread,
Feb 4, 2026, 5:53:18 AM (3 days ago) Feb 4
to Yoav Weiss (@Shopify), blink-dev, Chromestatus
Yes!

> If so, what would be an example use-case of wanting to add a post-commit handler as a result of pre-commit logic? What information does the pre-commit handler have that a post-commit logic doesn't?

Something like this, where the precommit handler performs some logic
to understand what to do with the request, and perhaps begins some
sort of shell, to be later populated by the handler:
```js
navigation.addEventListener("navigate", e => {
if (e.canIntercept) {
e.intercept({
async precommitHandler(controller) {
if (should_redirect(e.destination.url)) [
e.redirect(new_url);
return;
}
else if (should_cancel(destination.url)) {
throw new Error("cancel this navigation");
}
const contentPromise = fetchPageData();
const shell = await fetchPageShell();

shell.show_skeleton();

controller.addHandler(() => show_actual_data(await contentPromise));
}
}
});
```

Doing it this way is slightly more ergonomic than managing promises
outside of the intercept call.
See https://github.com/WICG/navigation-api/issues/66#issuecomment-1199002825
for old discussion about this.

Yoav Weiss (@Shopify)

unread,
Feb 4, 2026, 11:16:28 AM (3 days ago) Feb 4
to blink-dev, Noam Rosenthal, blink-dev, Chromestatus, Yoav Weiss
LGTM1

Alex Russell

unread,
Feb 4, 2026, 11:20:25 AM (3 days ago) Feb 4
to blink-dev, Yoav Weiss, Noam Rosenthal, blink-dev, Chromestatus
LGTM2

Vladimir Levin

unread,
Feb 4, 2026, 11:22:47 AM (3 days ago) Feb 4
to blink-dev, Alex Russell, Yoav Weiss, Noam Rosenthal, blink-dev, Chromestatus
Hey,

Can you please file signals for other browser vendors?

Thanks!
Vlad

Noam Rosenthal

unread,
Feb 5, 2026, 5:00:24 AM (2 days ago) Feb 5
to Vladimir Levin, blink-dev, Alex Russell, Yoav Weiss, Chromestatus
On Wed, Feb 4, 2026 at 4:22 PM Vladimir Levin <vmp...@chromium.org> wrote:
>
> Hey,
>
> Can you please file signals for other browser vendors?
>
> Thanks!
> Vlad

Aye. Updated the chromestatus.
Mozilla apparently has already implemented this as part of their
initial support for precommitHandler.
Webkit: https://github.com/WebKit/standards-positions/issues/612

Philip Jägenstedt

unread,
Feb 6, 2026, 5:19:38 AM (yesterday) Feb 6
to Noam Rosenthal, Vladimir Levin, blink-dev, Alex Russell, Yoav Weiss, Chromestatus
LGTM3

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAJn%3DMYZwBNgP_Kq-djzLjSTjJX%3DVuZco1SN6w4JPGiMB2bq_xQ%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages