This template should help get you started developing with Tauri in Blazor, C#, CSS and Javascript.
- run
dotnet watch
in thetauri-blazor-demo/src/
directory to start the frontend. - run
cargo tauri dev
in thetauri-blazor-demo/src-tauri/
directory to start the application in development mode.
- Add nuget package to your project.
dotnet add package SyminStudio.TauriApi --version 0.6.2
- Add following contents to your
Program.cs
file.
using TauriApi;
using TauriApi.Plugins;
// ...
builder.Services.AddTauriApi();
builder.Services.AddTauriPlugin<TauriOpener>();
// ...
- Add global using to the
_Imports.razor
file.
@using TauriApi
@using TauriApi.Plugins
- Now you can inject and use api in your components.
@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.
- api/app
- api/core
- api/event
- api/image
- api/path
- api/webview (partial)
- api/webviewWindow (partial)
- api/window (partial)
- plugin/fs (wip)
- plugin/opener
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.