Skip to content

Two-way-binding for SupplyParameterFromQuery in Blazor #61962

@zachneu

Description

@zachneu

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Background

Blazor supports reading query string parameters using [SupplyParameterFromQuery], but there's currently no built-in way to reflect parameter changes back into the query string.

Problem

This makes it harder to:

  • Keep URL state in sync with the UI

  • Support shareable/bookmarkable/filterable views

  • Avoid manual calls to NavigationManager.NavigateTo(...) every time a parameter changes

Proposal

Introduce optional support for two-way query string binding, possibly via:

  • Convention-based binding (MyProp + MyPropChanged)

  • A dedicated directive: @bind-query="Search"

This would:

  • Populate SearchTerm from the query on load
  • Update the query string automatically on changes (e.g., from input)

Notes

  • Can use NavigationManager.NavigateTo(..., replace: true) internally to avoid history pollution
  • Should avoid unnecessary updates by comparing current and new URLs

Alternatives Considered

Manual URL management is possible but adds a lot of boilerplate and makes query string integration less discoverable and consistent.

Impact

Would improve support for modern SPAs where the query string is used as UI state (filters, tabs, search, etc.) and make Blazor more intuitive.

Describe the solution you'd like

Example

`@page "/search"
@bind-query="SearchTerm"

<input @Bind="SearchTerm" />

@code {
[Parameter]
public string SearchTerm { get; set; }

[Parameter]
public EventCallback<string> SearchTermChanged { get; set; }

}`

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions