Bromix.Blazor.BrowserAPI 1.0.0

Prefix Reserved
dotnet add package Bromix.Blazor.BrowserAPI --version 1.0.0                
NuGet\Install-Package Bromix.Blazor.BrowserAPI -Version 1.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="Bromix.Blazor.BrowserAPI" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Bromix.Blazor.BrowserAPI --version 1.0.0                
#r "nuget: Bromix.Blazor.BrowserAPI, 1.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.
// Install Bromix.Blazor.BrowserAPI as a Cake Addin
#addin nuget:?package=Bromix.Blazor.BrowserAPI&version=1.0.0

// Install Bromix.Blazor.BrowserAPI as a Cake Tool
#tool nuget:?package=Bromix.Blazor.BrowserAPI&version=1.0.0                

Bromix.Blazor.BrowserAPI

Dependency Injection

Register the service via Dependency Injection.

builder.Services
    .AddBrowserApi()
        .AddClipboardService()
        .AddHistoryService()
        .AddLocalStorageService();

Usage

Clipboard

Inject the IClipboardService in your Blazor Page or Component.

@inject IClipboardService ClipboardService
...
@code {
    private string text = "";
    
    private async Task WriteToClipboard()
    {
        await ClipboardService.WriteText("Hello World");
        text = await ClipboardService.ReadText();
    }
}

Storage

Inject the ILocalStorageService or ISessionStorageService in your Blazor Page or Component.

@inject ILocalStorageService LocalStorageService
...
@code {
    private string? _text;
    private int _count = 0;
    private string _keys = string.Empty;

    private async Task SetItem()
    {
        await LocalStorageService.SetItem("Say", "Hello World");
        _text = await LocalStorageService.GetItem("Say");
        _count = await LocalStorageService.GetLength();

        var keys = await LocalStorageService.GetKeys();
        _keys = string.Join(',', keys);
    }
}
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
1.0.0 2,664 12/10/2022
0.0.1-alpha-1 514 9/10/2022