Skip to content

feat: use Navigation API for location change detection with polling fallback#2136

Merged
aklinker1 merged 3 commits intowxt-dev:mainfrom
Aler1x:feat/locationchange-navigation-api
Feb 19, 2026
Merged

feat: use Navigation API for location change detection with polling fallback#2136
aklinker1 merged 3 commits intowxt-dev:mainfrom
Aler1x:feat/locationchange-navigation-api

Conversation

@Aler1x
Copy link
Contributor

@Aler1x Aler1x commented Feb 16, 2026

Overview

wxt:locationchange used to rely on polling location.href every second, so URL updates (e.g. SPA navigations) were detected with up to 1s delay. This change uses the Navigation API when available: we subscribe to the navigate event so URL changes are handled immediately and no timer is used. In environments where the Navigation API is not available (e.g. older Firefox or Safari), behavior is unchanged and we keep the existing 1s polling. No new APIs for extension authors and no breaking changes.

Manual Testing

  1. Build WXT and the demo: pnpm --filter wxt build then pnpm --filter wxt-demo build.
  2. Load the unpacked extension from packages/wxt-demo/.output/chrome-mv3 (or equivalent for your build).
  3. Open a site that uses client-side navigation (e.g. the demo’s *://*.crunchyroll.com/*), open DevTools → Console.
  4. Navigate within the site (links that change the URL without full reload). You should see Location changed: <newUrl> <oldUrl> and Watching for location change....
  5. (Optional) In a Navigation API–capable browser the event fires immediately; with the polling fallback (e.g. force it by disabling the API in code or using an older browser) the same log appears within ~1s.

Related Issue

This PR closes #1567

@netlify
Copy link

netlify bot commented Feb 16, 2026

Deploy Preview for creative-fairy-df92c4 ready!

Name Link
🔨 Latest commit e05688e
🔍 Latest deploy log https://app.netlify.com/projects/creative-fairy-df92c4/deploys/69966504b64aa200088be435
😎 Deploy Preview https://deploy-preview-2136--creative-fairy-df92c4.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@aklinker1 aklinker1 changed the title feat(wxt): use Navigation API for location change detection with polling fallback feat: use Navigation API for location change detection with polling fallback Feb 19, 2026
Copy link
Member

@aklinker1 aklinker1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, looks like Firefox just added support for this event in January.

Was wondering why I didn't know about it? But it's been around for awhile in other browsers... Oh well, good to have it now!

@aklinker1 aklinker1 enabled auto-merge (squash) February 19, 2026 01:11
@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 19, 2026

Open in StackBlitz

@wxt-dev/analytics

npm i https://pkg.pr.new/@wxt-dev/analytics@2136

@wxt-dev/auto-icons

npm i https://pkg.pr.new/@wxt-dev/auto-icons@2136

@wxt-dev/browser

npm i https://pkg.pr.new/@wxt-dev/browser@2136

@wxt-dev/i18n

npm i https://pkg.pr.new/@wxt-dev/i18n@2136

@wxt-dev/module-react

npm i https://pkg.pr.new/@wxt-dev/module-react@2136

@wxt-dev/module-solid

npm i https://pkg.pr.new/@wxt-dev/module-solid@2136

@wxt-dev/module-svelte

npm i https://pkg.pr.new/@wxt-dev/module-svelte@2136

@wxt-dev/module-vue

npm i https://pkg.pr.new/@wxt-dev/module-vue@2136

@wxt-dev/runner

npm i https://pkg.pr.new/@wxt-dev/runner@2136

@wxt-dev/storage

npm i https://pkg.pr.new/@wxt-dev/storage@2136

@wxt-dev/unocss

npm i https://pkg.pr.new/@wxt-dev/unocss@2136

@wxt-dev/webextension-polyfill

npm i https://pkg.pr.new/@wxt-dev/webextension-polyfill@2136

wxt

npm i https://pkg.pr.new/wxt@2136

commit: e05688e

@codecov
Copy link

codecov bot commented Feb 19, 2026

Codecov Report

❌ Patch coverage is 11.11111% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.05%. Comparing base (f604208) to head (e05688e).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ackages/wxt/src/utils/internal/location-watcher.ts 11.11% 12 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2136      +/-   ##
==========================================
+ Coverage   75.90%   76.05%   +0.15%     
==========================================
  Files         113      113              
  Lines        3034     3045      +11     
  Branches      680      683       +3     
==========================================
+ Hits         2303     2316      +13     
+ Misses        646      643       -3     
- Partials       85       86       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@aklinker1 aklinker1 merged commit 173161c into wxt-dev:main Feb 19, 2026
18 checks passed
@github-actions
Copy link
Contributor

Thanks for helping make WXT better!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Improved wxt:locationchange

2 participants