BQuery 4.0.1
dotnet add package BQuery --version 4.0.1
NuGet\Install-Package BQuery -Version 4.0.1
<PackageReference Include="BQuery" Version="4.0.1" />
<PackageVersion Include="BQuery" Version="4.0.1" />
<PackageReference Include="BQuery" />
paket add BQuery --version 4.0.1
#r "nuget: BQuery, 4.0.1"
#:package BQuery@4.0.1
#addin nuget:?package=BQuery&version=4.0.1
#tool nuget:?package=BQuery&version=4.0.1
BQuery
BQuery is a Blazor helper library for JavaScript interop (inspired by jQuery).
It provides:
- Element DOM helpers (
Attr, class/style helpers) - Element measurement and position APIs
- Viewport measurement APIs
- Window event binding with .NET callbacks
- Element drag helpers
Target Frameworks
| BQuery | .NET |
|---|---|
| 4.x | .NET 8.0 / .NET 10.0 |
| 3.x | .NET 6 |
| 2.x | .NET 5 |
Breaking changes (4.0.0)
If you're upgrading from 3.x, please review the following API and platform changes:
- Target frameworks changed: BQuery 4.x targets .NET 8.0 and .NET 10.0 only. .NET 6 is no longer supported.
- Startup extensions removed: the old
AspNetExtensionspackage surface (for exampleUseBQuery(...)) was removed. Use DI registration withAddBQuery()and load the static asset from_content/BQuery/dist/.... - Resize callback payload changed: resize handlers now use
ResizeEventArgs(with named properties like width/height) instead of positional payload patterns.
Upgrade checklist
- Update your app TFM to .NET 8+.
- Replace legacy startup extension usage with
builder.Services.AddBQuery();. - Ensure your host page (or startup script flow) loads
_content/BQuery/dist/bQuery.min.js. - Update resize event handlers to
OnResizeAsync(ResizeEventArgs args)/OnResize(ResizeEventArgs args).
Install
dotnet add package BQuery
Quick Start
1. Register services
builder.Services.AddBQuery();
If using Interactive Auto render mode, the service needs to be registered in both the App and App.Client simultaneously.
2. Load the script
Add this script to your host page:
<script src="_content/BQuery/dist/bQuery.min.js"></script>
The repository samples use the UMD build (bQuery.min.js).
WASM example (wwwroot/index.html)
<script src="_content/BQuery/dist/bQuery.min.js"></script>
<script src="_framework/blazor.webassembly.js"></script>
Server example (Pages/_Host.cshtml)
<script src="_content/BQuery/dist/bQuery.min.js"></script>
<script src="_framework/blazor.server.js"></script>
Auto Mode (App.razor)
<script src="_content/BQuery/dist/bQuery.min.js"></script>
<script src="@Assets["_framework/blazor.web.js"]"></script>
3. Use Bq in components
@inject Bq bq
@implements IAsyncDisposable
@code {
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (!firstRender)
{
return;
}
await bq.AddWindowEventListener<ResizeEventArgs>(WindowEvent.OnResize, OnResizeAsync);
}
private Task OnResizeAsync(ResizeEventArgs args)
{
Console.WriteLine($"Viewport: {args.Width} x {args.Height}");
return Task.CompletedTask;
}
public async ValueTask DisposeAsync()
{
// Remove only this component's callback. Other subscribers share the scope.
await bq.RemoveWindowEventListener<ResizeEventArgs>(WindowEvent.OnResize, OnResizeAsync);
}
}
Common Usage
Viewport
var width = await bq.Viewport.GetWidthAsync();
var height = await bq.Viewport.GetHeightAsync();
var scrollTop = await bq.Viewport.GetScrollTopAsync();
Element APIs (ElementReference extensions)
var size = await element.GetWidthAndHeightAsync();
var docPos = await element.GetPositionInDocAsync();
await element.AddCls("is-active");
await element.Css("display", "none");
await element.RemoveCls("is-active");
Drag
await bq.Drag.BindDragAsync(dialog, new DragOptions
{
InViewport = true,
DragElement = dialogHeader
});
await bq.Drag.ResetDragPositionAsync(dialog, new DragOptions
{
DragElement = dialogHeader
});
await bq.Drag.RemoveDragAsync(dialog, new DragOptions
{
DragElement = dialogHeader
});
User agent
var ua1 = await bq.GetUserAgentAsync();
var ua2 = await jsRuntime.GetUserAgentAsync(); // IJSRuntime extension
API Docs
Samples
Sample/BQuery.Sample.WasmSample/BQuery.Sample.ServerSample/BQuery.Sample.Client— shared WebAssembly bootstrap for Wasm and AutoSample/BQuery.Sample.CommonSample/BQuery.Sample.Auto
The three .NET 10 hosts share the same English interactive laboratory. Server (5301), Wasm (5302), and Auto (5303) use Interactive Server, WebAssembly, and Auto respectively. See Sample guide and coverage for startup commands, routes, lifecycle notes and verification.
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.AspNetCore.Components.Web (>= 10.0.4)
- Microsoft.AspNetCore.Components.WebAssembly (>= 10.0.4)
- Microsoft.Extensions.Hosting.Abstractions (>= 10.0.4)
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.24)
- Microsoft.AspNetCore.Components.WebAssembly (>= 8.0.24)
- Microsoft.Extensions.Hosting.Abstractions (>= 8.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 4.0.1 | 72 | 9/8/2026 |
| 4.0.0 | 169 | 4/8/2026 |
| 4.0.0-preview.260311.1 | 82 | 3/11/2026 |
| 3.1.0 | 2,617 | 2/7/2023 |
| 3.0.3 | 582 | 10/4/2022 |
| 3.0.2 | 617 | 7/12/2022 |
| 3.0.1 | 541 | 11/27/2021 |
| 2.0.2 | 747 | 3/13/2021 |
| 2.0.1 | 731 | 3/13/2021 |
| 1.0.1 | 691 | 6/8/2020 |
| 1.0.0 | 718 | 5/19/2020 |
| 0.2.0-preivew | 449 | 5/6/2020 |
| 0.1.0-preivew | 473 | 5/2/2020 |