Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/elringus/bootsharp
Compile C# solution into single-file ES module with auto-generated JavaScript bindings and type definitions
https://github.com/elringus/bootsharp
bun codegen csharp deno interop js node ts typescript wasm
Last synced: 28 days ago
JSON representation
Compile C# solution into single-file ES module with auto-generated JavaScript bindings and type definitions
- Host: GitHub
- URL: https://github.com/elringus/bootsharp
- Owner: elringus
- License: mit
- Created: 2021-11-12T18:43:18.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T15:36:18.000Z (6 months ago)
- Last Synced: 2024-05-23T02:23:00.142Z (6 months ago)
- Topics: bun, codegen, csharp, deno, interop, js, node, ts, typescript, wasm
- Language: C#
- Homepage: https://bootsharp.com
- Size: 3.7 MB
- Stars: 647
- Watchers: 16
- Forks: 34
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# 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](https://emscripten.org/docs/porting/connecting_cpp_and_javascript/embind.html) for C++ or [wasm-bindgen](https://github.com/rustwasm/wasm-bindgen) for Rust.
![](https://raw.githubusercontent.com/elringus/bootsharp/main/docs/public/img/banner.png)
## 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://bootsharp.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](https://react.dev) and [Svelte](https://svelte.dev).
### Why not `System.JavaScript`?
Bootsharp itself is built on top of [System.Runtime.InteropServices.JavaScript](https://learn.microsoft.com/en-us/aspnet/core/blazor/javascript-interoperability/import-export-interop?view=aspnetcore-8.0) introduced in .NET 7.
If you're looking to expose simple library API to JavaScript and don't need type declarations, Bootsharp would probably be an overkill. However, .NET's interop is low-level, doesn't support passing custom types by value and requires lots of boilerplate to author the bindings. It's impractical for large API surfaces.
With Bootsharp, you'll be able to just feed it your domain-specific interfaces and use them seamlessly from the other side, as if they were originally authored in TypeScript (and vice-versa). Additionally, Bootsharp provides an option to bundle all the binaries into single-file ES module and patches .NET's internal JavaScript code to make it compatible with constrained runtime environments, such as VS Code [web extensions](https://code.visualstudio.com/api/extension-guides/web-extensions).