Bootsharp.Common 0.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bootsharp.Common --version 0.5.0
                    
NuGet\Install-Package Bootsharp.Common -Version 0.5.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="Bootsharp.Common" Version="0.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bootsharp.Common" Version="0.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Bootsharp.Common" />
                    
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 Bootsharp.Common --version 0.5.0
                    
#r "nuget: Bootsharp.Common, 0.5.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.
#:package Bootsharp.Common@0.5.0
                    
#: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=Bootsharp.Common&version=0.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Bootsharp.Common&version=0.5.0
                    
Install as a Cake Tool

<p align="center"> <a href="https://sharp.elringus.com" target="_blank" rel="noopener noreferrer"> <img width="200" src="https://raw.githubusercontent.com/elringus/bootsharp/main/docs/public/favicon.svg" alt="Bootsharp"> </a> </p> <br/> <p align="center"> <a href="https://www.nuget.org/packages/Bootsharp"><img src="https://img.shields.io/nuget/v/Bootsharp" alt="nuget"></a> <a href="https://codefactor.io/repository/github/elringus/bootsharp/overview/main"><img src="https://codefactor.io/repository/github/elringus/bootsharp/badge/main" alt="codefactor"></a> <a href="https://codecov.io/gh/elringus/bootsharp"><img src="https://codecov.io/gh/elringus/bootsharp/branch/main/graph/badge.svg?token=AAhei51ETt" alt="codecov"></a> <a href="https://github.com/elringus/bootsharp/actions/workflows/codeql.yml"><img src="https://github.com/elringus/bootsharp/actions/workflows/codeql.yml/badge.svg" alt="codeql"></a> </p> <br/>

Use C# in web apps with comfort

Bootsharp streamlines consuming .NET C# apps and libraries in web projects. It's ideal for building web applications, where domain (backend) is authored in .NET C#, while the UI (frontend) is a standalone TypeScript or JavaScript project. Think of it as Embind for C++ or wasm-bindgen for Rust.

alternate text is missing from this package README image

Features

✨ High-level C# ↔ TypeScript interop

📦 Embeds binaries to single-file ES module

🗺️ Works in browsers and JS runtimes (Node, Deno, Bun)

⚡ Generates bindings and types over C# interfaces

🏷️ Supports interop over object instances

🛠️ Allows customizing emitted bindings

🔥 Supports WASM multi-threading, AOT, trimming

🎬 Get Started

https://sharp.elringus.com/guide/getting-started

Why not Blazor?

In contrast to solutions like Blazor, which attempt to bring the entire web platform inside .NET, Bootsharp facilitates high-level interoperation between C# and TypeScript, allowing to build the UI layer under its natural ecosystem using industry-standard tooling and frameworks, such as React and Svelte.

Why not System.JavaScript?

Bootsharp itself is built on top of System.Runtime.InteropServices.JavaScript introduced in .NET 7.

If you need to expose a simple library API to JavaScript and don't require type declarations, Bootsharp is probably overkill. However, .NET's interop is low-level, lacks support for passing custom types by value, and requires extensive boilerplate to define bindings, making it impractical for large API surfaces.

With Bootsharp, you can simply provide your domain-specific interfaces and use them seamlessly on the other side, as if they were originally authored in TypeScript (and vice versa). This ensures a clear separation of concerns: your domain codebase won't be aware of the JavaScript environment—no need to annotate methods for interop or specify marshalling hints for arguments.

For example, consider the following abstract domain code:

public record Data (string Info, IReadOnlyList<Item> Items);
public record Result (View Header, View Content);
public interface IProvider { Data GetData (); }
public interface IGenerator { Result Generate (); }

public class Generator (IProvider provider) : IGenerator
{
    public Result Generate ()
    {
        var data = provider.GetData();
        // Process the data and generate result.
        return result;
    }
}

— the code doesn't use any JavaScript-specific APIs, making it fully testable and reusable. To expose it to JavaScript, all we need to do is add the following to Program.cs in a separate project for the WASM target:

using Bootsharp;
using Bootsharp.Inject;
using Microsoft.Extensions.DependencyInjection;

[assembly: JSImport(typeof(IProvider))]
[assembly: JSExport(typeof(IGenerator))]

// Bootsharp auto-injects implementation for 'IProvider'
// from JS and exposes 'Generator' APIs to JS.
new ServiceCollection()
    .AddBootsharp()
    .AddSingleton<IGenerator, Generator>()
    .BuildServiceProvider()
    .RunBootsharp();

— we can now provide implementation for IProvider and use Generator in JavaScript/TypeScript:

import bootsharp, { Provider, Generator } from "bootsharp";

// Implement 'IProvider'.
Provider.getData = () => ({
    info: "...",
    items: []
});

await bootsharp.boot();

// Use 'Generator'.
const result = Generator.generate();
Product Compatible and additional computed target framework versions.
.NET net9.0 is compatible.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  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.
  • net9.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Bootsharp.Common:

Package Downloads
Bootsharp

Use C# in web apps with comfort.

Bootsharp.Inject

Dependency injection extensions for Bootsharp.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
0.6.3 6,011 5/11/2025
0.6.2 465 5/6/2025
0.6.1 464 4/5/2025
0.6.0 503 3/30/2025
0.5.0 409 3/29/2025
0.4.0 495 1/5/2025
0.3.3 1,631 9/23/2024
0.3.2 3,727 5/28/2024
0.3.1 1,140 2/7/2024
0.3.0 462 2/5/2024
0.2.0 875 1/23/2024
0.1.3 611 1/6/2024
0.1.2 494 1/5/2024
0.1.1 541 1/1/2024
0.1.0 498 12/31/2023