-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Description
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