Skip to content

syminomega/TauriBlazor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tauri + Blazor

This template should help get you started developing with Tauri in Blazor, C#, CSS and Javascript.

Recommended IDE Setup

Getting Started

  1. run dotnet watch in the tauri-blazor-demo/src/ directory to start the frontend.
  2. run cargo tauri dev in the tauri-blazor-demo/src-tauri/ directory to start the application in development mode.

How To Use

  1. Add nuget package to your project.
dotnet add package SyminStudio.TauriApi --version 0.6.2
  1. Add following contents to your Program.cs file.
using TauriApi;
using TauriApi.Plugins;
// ...
builder.Services.AddTauriApi();
builder.Services.AddTauriPlugin<TauriOpener>();
// ...
  1. Add global using to the _Imports.razor file.
@using TauriApi
@using TauriApi.Plugins
  1. 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.

Supported APIs

The module @tauri-apps/api/{moduleName} is mapped to Tauri.{ModuleName} property. The constructor of the class is mapped to Tauri.{ModuleName}.Create{ClassName}() method. The plugins are mapped to Tauri{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

Warning

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.

About

Developing desktop appliction with Tauri in Blazor, C#, CSS and Javascript

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published