Skip to content

eds2code/lara

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lara Web Engine License: Apache 2.0 NuGet version Download count Build Status Coverage Status

Lara is a library for developing web user interfaces with server-side rendering. Lara gives you full control of the client's HTML Document Object Model (DOM) from the server in 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.Threading.Tasks;

namespace SampleProject
{
    class Program
    {
        static async Task Main()
        {
            using var app = new Application();
            await app.Start(new StartServerOptions
            {
                // launches user's default web browser and terminates when closed
                Mode = ApplicationMode.BrowserApp,
                
                // search for classes decorated with Lara attributes and load them
                PublishAssembliesOnStart = true
            });
            await app.WaitForShutdown();
        }
    }

    [LaraPage(Address = "/")]
    class MyPage : IPage
    {
        int counter = 0;

        public Task OnGet()
        {
            var button = Element.Create("button");
            button.InnerText = "Click me";
            button.On("click", () =>
            {
                counter++;
                button.InnerText = $"Clicked {counter} times";
                return Task.CompletedTask;
            });
            LaraUI.Page.Document.Body.AppendChild(button);
            return Task.CompletedTask;
        }
    }
}

Other resources available for building web pages are the LaraBuilder class, Web Components, and Reactive Programming.

Integrating Lara into an existing web server

To add Lara to an existing ASP.NET Core server, use:

public void Configure(IApplicationBuilder app)  
{  
    app.UseLara(new LaraOptions
    {
        // configuration options
    });
} 

Getting started

There's no need to download this repository to use Lara, instead, there's a NuGet package.

To start, create a new project and add the NuGet package Integrative.Lara. In Visual Studio go to Tools -> NuGet Package Manager -> Manage NuGet packages for Solution, then search for the package 'Integrative.Lara'.

In your project, copy and paste the sample application.

This repository contains a sample project.

The wiki has the documentation for using Lara.

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.

The source code contains a sample project. The documentation is available in the wiki.

How to contribute

Please send feedback! Issues, questions, suggestions, requests for features, and success stories. Please let me know by either opening an issue or by direct message. Thank you!

If you like Lara, please give it a star - it helps!

Credits

Thanks to JetBrains for the licenses of Rider and DotCover.

JetBrains

About

Lara Web Engine is a lightweight C# Web UI framework for server-side DOM rendering.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 91.3%
  • TypeScript 4.9%
  • JavaScript 3.8%