Awesome
Lara Web Engine
Lara is a server-side rendering framework for developing web user interfaces using C#.
"It is similar to server-side Blazor, but is much more lightweight and easier to install. For example, while any type of Blazor requires a whole SDK, Lara is just a NuGet package." ScientificProgrammer.net
Sample application
using Integrative.Lara;
using System;
using System.Threading.Tasks;
namespace SampleApp
{
public static class Program
{
public static async Task Main()
{
// create and start application
const int port = 8182;
using var app = new Application();
app.PublishPage("/", () => new MyCounterComponent { Value = 5 });
await app.Start(new StartServerOptions { Port = port });
// print address on console
var address = $"http://localhost:{port}";
Console.WriteLine($"Listening on {address}/");
// helper function to launch browser (comment out as needed)
LaraUI.LaunchBrowser(address);
// wait for ASP.NET Core shutdown
await app.WaitForShutdown();
}
}
internal class MyCounterComponent : WebComponent
{
private int _value; // triggers PropertyChanged event
public int Value { get => _value; set => SetProperty(ref _value, value); }
public MyCounterComponent()
{
ShadowRoot.Children = new Node[]
{
new HtmlDivElement() // on PropertyChanged, assigns InnerText
.Bind(this, x => x.InnerText = Value.ToString()),
new HtmlButtonElement
{ InnerText = "Increase" }
.Event("click", () => Value++)
};
}
}
}
Adding Lara to an existing web server application
To add Lara to an existing ASP.NET Core server, add to the Startup class or equivalent:
private readonly Application _laraApp = new Application();
public void Configure(IApplicationBuilder app)
{
app.UseLara(_laraApp, new LaraOptions
{
// configuration options
});
}
Creating Desktop applications
To create a desktop container for your web app, here's a few options:
- electron.js combined with electron-cgi library
- Chromely
- neutralinojs
Getting started
There's no need to download this repository to use Lara, instead, there's a NuGet package.
Check out the wiki documentation
How does Lara work?
Whenever the browser triggers a registered event (e.g. click on a button), it sends to the server a message saying that the button was clicked. The server executes the code associated with the event, manipulating the server's copy of the page, and replies a JSON message with the delta between server and client.
How to contribute
Please send feedback! Issues, questions, suggestions, requests for features, and success stories. Please let me know by either opening an issue. Thank you!
If you like Lara, please give it a star - it helps!
Credits
Thanks to JetBrains for the licenses of Rider and DotCover.