Exposed Tauri APIs for Blazor.
$ dotnet add package SyminStudio.TauriApiThis template should help get you started developing with Tauri in Blazor, C#, CSS and Javascript.
dotnet watch in the tauri-blazor-demo/src/ directory to start the frontend.cargo tauri dev in the tauri-blazor-demo/src-tauri/ directory to start the application in development mode.dotnet add package SyminStudio.TauriApi --version 0.6.2
Program.cs file.using TauriApi;
using TauriApi.Plugins;
// ...
builder.Services.AddTauriApi();
builder.Services.AddTauriPlugin<TauriOpener>();
// ...
_Imports.razor file.@using TauriApi
@using TauriApi.Plugins
@inject Tauri Tauri
@inject TauriOpener Opener
<YourComponents/>
@code{
private string? GreetInput { get; set; }
private string? GreetMsg { get; set; }
private async Task GreetAsync()
{
GreetMsg = await Tauri.Core.Invoke<string>("greet", new { name = GreetInput });
await Opener.OpenPath("https://demosite")
}
}
Warning: If you are using structured data as return type from rust, make sure that the data is serialized into camel case format, or received as snake case format.
The module
@tauri-apps/api/{moduleName}is mapped toTauri.{ModuleName}property. The constructor of the class is mapped toTauri.{ModuleName}.Create{ClassName}()method. The plugins are mapped toTauri{PluginName}class.
This package is not yet ready for production. It is a work in progress and should not be used in production applications. It is intended for development and testing purposes only. Use at your own risk. This package only supports Tauri 2.0 since version 0.3.0.