Agibuild.Avalonia.WebView 0.1.18-preview

This is a prerelease version of Agibuild.Avalonia.WebView.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Agibuild.Avalonia.WebView --version 0.1.18-preview
                    
NuGet\Install-Package Agibuild.Avalonia.WebView -Version 0.1.18-preview
                    
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="Agibuild.Avalonia.WebView" Version="0.1.18-preview" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Agibuild.Avalonia.WebView" Version="0.1.18-preview" />
                    
Directory.Packages.props
<PackageReference Include="Agibuild.Avalonia.WebView" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Agibuild.Avalonia.WebView --version 0.1.18-preview
                    
#r "nuget: Agibuild.Avalonia.WebView, 0.1.18-preview"
                    
#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.
#:package Agibuild.Avalonia.WebView@0.1.18-preview
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Agibuild.Avalonia.WebView&version=0.1.18-preview&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Agibuild.Avalonia.WebView&version=0.1.18-preview&prerelease
                    
Install as a Cake Tool

<p align="center"> <img src="https://img.shields.io/nuget/v/Agibuild.Avalonia.WebView?logo=nuget&label=NuGet&color=004880&style=flat-square" /> <img src="https://img.shields.io/nuget/dt/Agibuild.Avalonia.WebView?logo=nuget&label=Downloads&color=00a86b&style=flat-square" /> <a href="https://github.com/AGIBuild/Agibuild.Avalonia.WebView/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/AGIBuild/Agibuild.Avalonia.WebView/ci.yml?label=CI&logo=github&style=flat-square" /></a> <img src="https://img.shields.io/badge/License-MIT-yellow?style=flat-square" /> </p>

<h1 align="center">Agibuild.Avalonia.WebView</h1>

<p align="center"> <strong>Electron-level web productivity. Avalonia-native performance, control, and security.</strong> </p>


Product direction update
This project is now driven by the Electron Replacement Foundation goal (Roadmap Phase 5).
We are building a hybrid application platform, not just a WebView control.

Why This Exists

Teams migrating from Electron usually want two things at the same time:

  1. Keep web development speed (React/Vue/Svelte, HMR, fast iteration)
  2. Regain native footprint, stronger security boundaries, and deterministic host behavior

Traditional WebView wrappers often solve rendering, but still leave you to hand-build:

  • string-based host/web IPC
  • policy governance for host capabilities
  • diagnosable runtime behavior for CI and automation
  • scalable app-shell patterns across platforms

Agibuild.Avalonia.WebView targets that full gap.

What This Is Now (Not Just a Control)

1) Typed bridge at the center

  • [JsExport] / [JsImport] contracts
  • source-generated C# and JS-facing proxies
  • AOT-safe, reflection-free path

2) Typed capability gateway for host/system operations

  • desktop/system capabilities converge into one typed entry model
  • avoid scattered host API calls in app-layer code

3) Policy-first runtime semantics

  • policy is evaluated before capability/provider execution
  • deterministic outcomes: allow / deny / failure

4) Agent-friendly diagnostics

  • machine-checkable diagnostics for critical runtime flows
  • usable by CI, test automation, and AI agents

5) Web-first template flow

  • starter path optimized for web-first hybrid desktop/mobile delivery
  • minimal host glue, typed contracts preserved end-to-end

Roadmap Alignment

Phase Theme Status
Phase 0 Foundation ✅ Done
Phase 1 Type-Safe Bridge ✅ Done
Phase 2 SPA Hosting ✅ Core Done
Phase 3 Polish & GA ✅ Done
Phase 4 Application Shell ✅ Done
Phase 5 Electron Replacement Foundation ✅ Completed

Read more:

Platform Coverage

Platform Engine Status
Windows WebView2 Preview
macOS WKWebView Preview
Linux WebKitGTK Preview
iOS WKWebView Preview
Android Android WebView Preview

Avalonia provides an official commercial WebView option.
This project focuses on an open, cross-platform, contract-driven hybrid app platform.


60-Second Start

Install package:

dotnet add package Agibuild.Avalonia.WebView

Enable in Program.cs:

AppBuilder.Configure<App>()
    .UsePlatformDetect()
    .UseAgibuildWebView()
    .StartWithClassicDesktopLifetime(args);

Add control in XAML:

<Window xmlns:wv="using:Agibuild.Avalonia.WebView">
    <wv:WebView x:Name="WebView" Source="https://example.com" />
</Window>

For full guides:


Typed Bridge in Practice

Expose C# service to JavaScript:

[JsExport]
public interface IGreeterService
{
    Task<string> Greet(string name);
}

public sealed class GreeterService : IGreeterService
{
    public Task<string> Greet(string name) => Task.FromResult($"Hello, {name}!");
}

webView.Bridge.Expose<IGreeterService>(new GreeterService());

Call from JavaScript:

const msg = await window.agWebView.rpc.invoke("GreeterService.greet", { name: "World" });

Call JavaScript from C#:

[JsImport]
public interface INotificationService
{
    Task ShowNotification(string message);
}

var notifications = webView.Bridge.GetProxy<INotificationService>();
await notifications.ShowNotification("File saved!");

Web-First SPA Hosting

Production (embedded assets):

webView.EnableSpaHosting(new SpaHostingOptions
{
    EmbeddedResourcePrefix = "wwwroot",
    ResourceAssembly = typeof(MainWindow).Assembly,
});

await webView.NavigateAsync(new Uri("app://localhost/index.html"));

Development (HMR proxy):

webView.EnableSpaHosting(new SpaHostingOptions
{
    DevServerUrl = "http://localhost:5173",  // Vite, webpack, etc.
});

Demo: Avalonia + React

Sample project: samples/avalonia-react/

Dashboard

<p align="center"><img src="docs/demo/images/dashboard.jpg" width="720" /></p>

Chat

<p align="center"><img src="docs/demo/images/chat.jpg" width="720" /></p>

Settings

<p align="center"><img src="docs/demo/images/settings.jpg" width="720" /></p>

Deep dive:


Capability Snapshot

  • OAuth / Web authentication (IWebAuthBroker)
  • Web dialog flows (IWebDialog)
  • Screenshot and PDF export
  • Cookie and command manager support
  • Environment options (DevTools, User-Agent, session modes)
  • Dependency injection integration

For detailed API usage, see:


Architecture at a Glance

┌──────────────────────────────────────────────────────────┐
│                   Your Avalonia App                     │
│                                                          │
│  ┌───────────┐   ┌─────────────┐   ┌─────────────────┐  │
│  │ WebView   │   │ Typed Bridge│   │ Capability Gate │  │
│  │ Control   │   │ C# <-> JS   │   │ Host/System API │  │
│  └─────┬─────┘   └──────┬──────┘   └────────┬────────┘  │
│        │                │                    │           │
│  ┌─────┴────────────────┴────────────────────┴────────┐  │
│  │         Runtime Core (policy-first execution)      │  │
│  │  Navigation · RPC · Shell · Diagnostics · Policy   │  │
│  └──────────────────────────┬──────────────────────────┘  │
│                             │ IWebViewAdapter             │
│  ┌──────────────────────────┴──────────────────────────┐  │
│  │      WKWebView · WebView2 · WebKitGTK · Android    │  │
│  └─────────────────────────────────────────────────────┘  │
└──────────────────────────────────────────────────────────┘

Template Workflow

dotnet new install Agibuild.Avalonia.WebView.Templates
dotnet new agibuild-hybrid -n MyApp
cd MyApp
dotnet run --project MyApp.Desktop

Quality Signals

Metric Value
Unit tests 766
Integration tests 149
Line coverage 95.87%
Branch coverage 84.8%
Method coverage 98.2%
nuke Test            # Unit + Integration (915 tests)
nuke Coverage        # Coverage report + threshold enforcement
nuke NugetPackageTest  # Pack → install → run smoke test
nuke TemplateE2E     # Template end-to-end test

License

MIT

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-android36.0 is compatible.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-ios18.0 is compatible.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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