BQuery 4.0.0
dotnet add package BQuery --version 4.0.0
NuGet\Install-Package BQuery -Version 4.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="BQuery" Version="4.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="BQuery" Version="4.0.0" />
<PackageReference Include="BQuery" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add BQuery --version 4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: BQuery, 4.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package BQuery@4.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=BQuery&version=4.0.0
#tool nuget:?package=BQuery&version=4.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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.AddWindowEventListeners(WindowEvent.OnResize, WindowEvent.OnScroll);
bq.WindowEvents.OnResizeAsync += OnResizeAsync;
}
private Task OnResizeAsync(ResizeEventArgs args)
{
Console.WriteLine($"Viewport: {args.Width} x {args.Height}");
return Task.CompletedTask;
}
public async ValueTask DisposeAsync()
{
// If listening for Window events
await bq.RemoveWindowEventListeners();
}
}
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.CommonSample/BlazorAppAuto
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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
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.0 | 89 | 4/8/2026 |
| 4.0.0-preview.260311.1 | 55 | 3/11/2026 |
| 3.1.0 | 2,584 | 2/7/2023 |
| 3.0.3 | 558 | 10/4/2022 |
| 3.0.2 | 592 | 7/12/2022 |
| 3.0.1 | 523 | 11/27/2021 |
| 2.0.2 | 729 | 3/13/2021 |
| 2.0.1 | 710 | 3/13/2021 |
| 1.0.1 | 673 | 6/8/2020 |
| 1.0.0 | 699 | 5/19/2020 |
| 0.2.0-preivew | 429 | 5/6/2020 |
| 0.1.0-preivew | 450 | 5/2/2020 |