JSVaporizer.NET.8
1.0.0
dotnet add package JSVaporizer.NET.8 --version 1.0.0
NuGet\Install-Package JSVaporizer.NET.8 -Version 1.0.0
<PackageReference Include="JSVaporizer.NET.8" Version="1.0.0" />
<PackageVersion Include="JSVaporizer.NET.8" Version="1.0.0" />
<PackageReference Include="JSVaporizer.NET.8" />
paket add JSVaporizer.NET.8 --version 1.0.0
#r "nuget: JSVaporizer.NET.8, 1.0.0"
#:package JSVaporizer.NET.8@1.0.0
#addin nuget:?package=JSVaporizer.NET.8&version=1.0.0
#tool nuget:?package=JSVaporizer.NET.8&version=1.0.0
JSVaporizer
Cut down on JavaScript. Write more C#.
A minimalistic .NET 8 WebAssembly library that lets you unify front-end and back-end logic without committing to a full framework like Blazor.
Why JSVaporizer?
Most ASP.NET Core apps need some front-end interactivity: DOM manipulation, event handlers, and data transformation. But juggling both JavaScript and C# can be messy:
- You end up writing repetitive JavaScript and JQuery boilerplate everywhere.
- Business logic is split across two languages, and you have to maintain it in two languages.
- Front-end code can become spaghetti.
JSVaporizer offers a middle ground:
- It’s lighter than a full SPA framework (like Blazor).
- It cuts down on JavaScript by letting you write front-end logic in C# — no major rewrites needed.
- It doesn’t lock you into any specific ecosystem. You can still add custom JavaScript or even build a Blazor-style persistent connection if you want.
Core Ideas
DTO-Centric
Define a DTO (Data Transfer Object) in C#. Transform it to (and from) the DOM using a Transformer. Keep your domain logic strongly typed and maintainable.DOM Facade in C#
Typical DOM calls likegetElementById,setAttribute, oraddEventListenerare wrapped in easy C# methods. No more copy-pasting JavaScript for every form or event handler.Minimal JavaScript
A tiny script loads the .NET WASM runtime, then delegates all serious logic (event handling, validation, data manipulation) to C#. You can still drop in small custom JS for specialized tasks—no big frameworks needed.Extensible in Four Ways
- Call arbitrary JS from C#: If you need a special function or a quick fix, register it in JSVaporizer’s function pool.
- Call arbitrary C# from JS (whitelisted methods): Perfect for callbacks or event hooks.
- Import your own JS modules via
[JSImport]. - Export your own C# methods to JavaScript via
[JSExport].
Works With .NET 8
Leverages the new Microsoft.NET.Runtime.WebAssembly.Sdk and .NET 8 JavaScript Interop APIs. Future .NET releases will likely make this story even stronger.
How It Works
Define a Transformer
ImplementITransformeror extend theTransformerbase class. Implement methods likeDtoToView(), which updates DOM fields from your C# DTO, andViewToDto(), which pulls form data back into the DTO.Register the Transformer
Make it discoverable via a registry key (e.g.,"MyCoolTransformer"), so JavaScript can call it by name. Or use any other approach (like a dictionary) to store your transformers.Use Minimal JavaScript
In your page’s JS, just import the WASM and call something likeTransformerInvoker.Invoke("MyCoolTransformer", dtoJSON);
That’s it: data is transformed, the DOM is updated, event handlers are attached—all in C#.
Add Custom Logic Where Needed
If you need extra JavaScript calls, register them in JSVaporizer’s JSFunctionPool.
If you want to push data from JavaScript to C#, whitelisting a C# method is just as easy.
Real-World Scenario
Forms and Validation
Let’s say you have a form with multiple fields and a “Submit” button. Instead of writing form-filling code in JS, you create a C# DTO (like AppointmentDto), then a Transformer that:
- Reads the
AppointmentDtoJSON and populates the form (DtoToView). - Hooks the button’s event listener in C#.
- On click, calls
ViewToDto(), validates the data, and maybe sends it to your server.
AJAX or Real-Time Calls
You can still do AJAX from minimal JS or adopt a more advanced persistent connection—JSVaporizer doesn’t restrict you. Want to do a quick fetch or jQuery call? Just drop in a small JS snippet and call it from C#.
Who Is It For?
- .NET Devs who want to unify front-end/back-end logic without going “all-in” on Blazor.
- Teams who hate duplicating logic in JavaScript and prefer static typing and .NET tooling.
- Projects that aren’t full SPAs but still need some front-end interactivity.
Who Is It Not For?
- Those heavily invested in SPA frameworks like React, Angular, or Vue.
- Developers who want a full Blazor experience (component model, two-way binding, etc.).
- Teams comfortable with polyglot front ends who don’t mind more JavaScript.
Try It Out or Contribute
- Open Source: We welcome pull requests, issues, and suggestions on GitHub.
- Lightweight: It’s just a small set of source files. Integrate it into your ASP.NET Core project or play around in a toy app.
- Compatible: As long as you’re targeting .NET 8 and run in a browser environment (WASM), you can use JSVaporizer!
Ready to dive in?
- Clone the repo.
- Check out the examples folder for a quick start.
- Submit your issues or pull requests—we’d love your feedback and contributions!
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. 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. |
-
net8.0
- No dependencies.
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 |
|---|