Skip to content

[desktop_webview_window]: addOnUrlRequestCallback not triggered on SPA (e.g. React) client-side route changes #418

@kunjaarogyatech

Description

@kunjaarogyatech

Hi, thank you for this helpful plugin!

I'm using desktop_webview_window in my Flutter Linux app to embed a webview. The addOnUrlRequestCallback works fine for traditional full-page navigations, but it's not triggered when navigating within a Single Page Application (SPA) such as a React app that uses client-side routing (e.g. React Router or Next.js).

Steps to Reproduce:

  1. Load a React-based SPA (e.g. a local or deployed React app) in the webview.
  2. Use the app's navigation (e.g. Use navigate or clicking on a element to route to another page).
  3. Observe that addOnUrlRequestCallback is not called on these URL changes.

Expected Behavior:

  1. The callback should also be triggered when the URL changes due to client-side routing in SPAs, not just for full-page navigations.
  2. Alternatively, we could have a new dedicated callback specifically for detecting URL changes in SPA apps.

Actual Behavior:
addOnUrlRequestCallback is only triggered for full page loads (e.g. window.location.href = '...') and not for history API-based routing (history.pushState, replaceState), which is commonly used in SPAs.

Environment:
OS: Linux
Flutter version: 3.29.2
Plugin version: ^0.2.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions