Skip to content

Conversation

@surajkewat72
Copy link

This commit addresses issue #14583 by changing the and
methods to accept as a parameter
instead of the raw type.

Changes:

  • Updated to accept parameter
  • Updated to accept parameter
  • Added helper method that converts to using the same logic as webview initialization (handles dev server proxying, app URLs, external URLs, and custom protocols)
  • Added comprehensive documentation examples for both methods

Benefits:

  • Type-safety: Ensures URLs passed to navigate use the same type as webview creation
  • Consistency: Uses the same URL handling logic as webview initialization
  • Fixes dev server proxy issues: Properly handles localhost/dev server URLs
  • Better API: More intuitive for developers using WebviewUrl elsewhere

Breaking Change:
This is a breaking change as the method signature has changed from:
pub fn navigate(&self, url: Url) -> crate::Result<()>
to:
pub fn navigate(&self, webview_url: WebviewUrl) -> crate::Result<()>

Users will need to update their code to use WebviewUrl instead of raw Url.

Migration example:
Before: webview.navigate("http://tauri.localhost/".parse()?) After: webview.navigate(WebviewUrl::App("index.html".into()))

Closes #14583

This commit addresses issue tauri-apps#14583 by changing the  and
 methods to accept  as a parameter
instead of the raw  type.

Changes:
- Updated  to accept  parameter
- Updated  to accept  parameter
- Added  helper method that converts  to
  using the same logic as webview initialization (handles dev server proxying,
  app URLs, external URLs, and custom protocols)
- Added comprehensive documentation examples for both methods

Benefits:
- Type-safety: Ensures URLs passed to navigate use the same type as webview creation
- Consistency: Uses the same URL handling logic as webview initialization
- Fixes dev server proxy issues: Properly handles localhost/dev server URLs
- Better API: More intuitive for developers using WebviewUrl elsewhere

Breaking Change:
This is a breaking change as the method signature has changed from:
  pub fn navigate(&self, url: Url) -> crate::Result<()>
to:
  pub fn navigate(&self, webview_url: WebviewUrl) -> crate::Result<()>

Users will need to update their code to use WebviewUrl instead of raw Url.

Migration example:
Before: webview.navigate("http://tauri.localhost/".parse()?)
After:  webview.navigate(WebviewUrl::App("index.html".into()))

Closes tauri-apps#14583
@surajkewat72 surajkewat72 requested a review from a team as a code owner November 30, 2025 08:00
@github-project-automation github-project-automation bot moved this to 📬Proposal in Roadmap Nov 30, 2025
@FabianLars FabianLars added the type: breaking change This issue or pull request will introduce a breaking change and requires major version bump label Nov 30, 2025
@FabianLars FabianLars added this to the 3.0 milestone Nov 30, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 30, 2025

Package Changes Through 0af5228

No changes.

Add a change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

Comment on lines +1670 to +1671
/// Converts a [`WebviewUrl`] to a [`Url`] using the same logic as webview initialization.
fn webview_url_to_url(&self, webview_url: WebviewUrl) -> crate::Result<Url> {

Choose a reason for hiding this comment

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

Can we share this logic between the two callsites instead of duplicating it?

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

Labels

type: breaking change This issue or pull request will introduce a breaking change and requires major version bump

Projects

Status: 📬Proposal

Development

Successfully merging this pull request may close these issues.

[feat] Webview::navigate should take WebviewUrl as param instead of raw Url

3 participants