Blazor.Javascript.Interop.Extensions
0.0.2
See the version list below for details.
dotnet add package Blazor.Javascript.Interop.Extensions --version 0.0.2
NuGet\Install-Package Blazor.Javascript.Interop.Extensions -Version 0.0.2
<PackageReference Include="Blazor.Javascript.Interop.Extensions" Version="0.0.2" />
paket add Blazor.Javascript.Interop.Extensions --version 0.0.2
#r "nuget: Blazor.Javascript.Interop.Extensions, 0.0.2"
// Install Blazor.Javascript.Interop.Extensions as a Cake Addin #addin nuget:?package=Blazor.Javascript.Interop.Extensions&version=0.0.2 // Install Blazor.Javascript.Interop.Extensions as a Cake Tool #tool nuget:?package=Blazor.Javascript.Interop.Extensions&version=0.0.2
Blazor.Javascript.Interop
Overview
Blazor.Javascript.Interop is a NuGet package designed as an extension library specifically for Blazor projects. It facilitates seamless interoperability between C# code in Blazor and JavaScript, empowering developers to incorporate JavaScript functionalities into their Blazor applications effortlessly.
Features
- Interoperability: Enables smooth communication between C# code in Blazor and JavaScript.
- Simplified Integration: Facilitates easy incorporation of JavaScript functionalities into Blazor applications.
- Boosted Productivity: Streamlines development workflows by eliminating complexities in bridging the gap between C# and JavaScript.
Installation
To install Blazor.Javascript.Interop, simply add the package to your Blazor project via NuGet Package Manager or the .NET CLI:
dotnet add package Blazor.Javascript.Interop
Usage
After installing the package, you can start using it in your Blazor project by following these steps:
Import the Namespace: Import the
Blazor.Javascript.Interop
namespace in your Blazor components where you intend to utilize JavaScript interop functionalities.@using Blazor.Javascript.Interop; @using Blazor.Javascript.Interop.Extensions;
Wrap your Router: Wrap the router component with the <WindowCascadingValue> component
// Example of invoking a JavaScript function from C# code <WindowCascadingValue> <Router AppAssembly="typeof(Program).Assembly"> <Found Context="routeData"> <RouteView RouteData="routeData" DefaultLayout="typeof(Layout.MainLayout)" /> <FocusOnNavigate RouteData="routeData" Selector="h1" /> </Found> </Router> </WindowCascadingValue>
Get the JSWindow object: Utilize the provided methods to invoke JavaScript functions from your C# code.
[CascadingParameter] public required JSWindow Window { get; set; }
Use the javascript methods: Check what are the methods ported to C# from javascript
private async Task CookieEnabledAsync() => cookieEnabled = await Window.Navigator.CookieEnabledAsync();
Compatibility
Blazor.Javascript.Interop is compatible with Blazor projects targeting both server-side and client-side hosting models.
Contributing
Contributions to Blazor.Javascript.Interop are welcome! If you have any ideas for improvements, new features, or encounter any issues, feel free to open an issue or submit a pull request on GitHub.
License
Blazor.Javascript.Interop is licensed under the MIT License.
Acknowledgements
This project is inspired by the growing need for seamless integration between C# and JavaScript in Blazor applications. Special thanks to the Blazor community for their continuous support and feedback.
Note: For more information, detailed examples, and updates, please refer to the GitHub repository. We appreciate your interest and hope Blazor.Javascript.Interop proves to be a valuable addition to your Blazor development toolkit!
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. |
-
net8.0
- Microsoft.AspNetCore.Components.Web (>= 8.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Blazor.Javascript.Interop.Extensions:
Package | Downloads |
---|---|
Blazor.Javascript.Interop
Blazor.Javascript.Interop is a NuGet package designed as an extension library specifically for Blazor projects. It facilitates seamless interoperability between C# code in Blazor and JavaScript, empowering developers to incorporate JavaScript functionalities into their Blazor applications effortlessly. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.0.4 | 97 | 9/23/2024 |
1.0.3 | 87 | 9/22/2024 |
1.0.2 | 84 | 9/20/2024 |
1.0.1 | 82 | 9/20/2024 |
1.0.0 | 89 | 9/20/2024 |
0.0.14 | 86 | 9/20/2024 |
0.0.13 | 83 | 9/20/2024 |
0.0.12 | 99 | 9/16/2024 |
0.0.11 | 96 | 9/16/2024 |
0.0.9 | 101 | 9/15/2024 |
0.0.8 | 97 | 9/12/2024 |
0.0.4 | 106 | 9/11/2024 |
0.0.3.3 | 160 | 4/12/2024 |
0.0.3.2 | 101 | 4/12/2024 |
0.0.3.1 | 103 | 4/12/2024 |
0.0.3 | 103 | 4/12/2024 |
0.0.2 | 103 | 4/9/2024 |
0.0.1 | 127 | 3/27/2024 |
0.0.1-beta | 72 | 3/27/2024 |