Hydro 0.13.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Hydro --version 0.13.0
NuGet\Install-Package Hydro -Version 0.13.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="Hydro" Version="0.13.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Hydro --version 0.13.0
#r "nuget: Hydro, 0.13.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.
// Install Hydro as a Cake Addin
#addin nuget:?package=Hydro&version=0.13.0

// Install Hydro as a Cake Tool
#tool nuget:?package=Hydro&version=0.13.0

Hydro


Bring stateful and reactive components to ASP.NET Core without writing JavaScript


Hydro is an extension to ASP.NET Core MVC and Razor Pages. It extends View Components to make them reactive and stateful with ability to communicate with each other without page reloads. As a result, you can create powerful components and make your application to feel like SPA with zero or minimal amount of the JavaScript code (depending on the needs) and without separate front-end build step. It can be used in new or existing ASP.NET Core applications.

Hydro utilizes the following technologies to make it all work:

  • Razor views (*.cshtml)
    Razor views form the backbone of Hydro's UI generation. They allow for a familiar, server-side rendering strategy that has been a foundation of .NET web development for many years. These *.cshtml files enable a seamless mix of HTML and C# code, allowing for robust and dynamic webpage generation.

  • AJAX
    AJAX calls are used to communicate between the client and the server, specifically to send the application state to the server, receive updates and responses back, and then store this state to be used in subsequent requests. This ensures that each request has the most up-to-date context and information.

  • Alpine.js
    Alpine.js stands as a base for requests execution and DOM swapping. But beyond that, Alpine.js also empowers users by providing a framework for adding rich, client-side interactivity to the standard HTML. So, not only does it serve Hydro's internal operations, but it also provides an expansion point for users to enhance their web applications with powerful, interactive experiences.

Documentation

Samples

Installation

In ASP.NET Core Razor Pages / MVC project 6.0+ install Hydro package:

dotnet add package Hydro

If you don't have application yet, you can create it first:

dotnet new webapp -o MyApp
cd MyApp

In your application's startup code (either Program.cs or Startup.cs):

builder.Services.AddHydro();

...

app.UseHydro(builder.Environment);

In _ViewImports.cshtml add:

@addTagHelper *, {Your project assembly name}
@addTagHelper *, Hydro

In layout's head tag:

<meta name="hydro-config" />
<script defer src="~/hydro/hydro.js" asp-append-version="true"></script>
<script defer src="~/hydro/alpine.js" asp-append-version="true"></script>

Quick start

To create Hydro component, go to your components folder, for example in case of Razor Pages: ~/Pages/Components/, and create these files:



@model Counter

<div>
  Count: <strong>@Model.Count</strong>
  <button hydro-on:click="@(() => Model.Add())">
    Add
  </button>
</div>
// Counter.cs

public class Counter : HydroComponent
{
    public int Count { get; set; }
    
    public void Add()
    {
        Count++;
    }
}

Usage

To use your new component, you can render it in your Razor Page (e.g. Index.cshtml) in two ways:

via Hydro tag helper:

...
<hydro name="Counter"/>
...

via ASP.NET Core tag helper:

...
<vc:counter/>
...

or via extension method:

...
@await Component.Hydro("Counter")
...

And voilà! You can test your component by clicking on the Add button.

Apps using Hydro

External libraries

Hydro repository contains Alpine.js libraries MIT licensed.

License

Hydro is Copyright © Krzysztof Jeske and other contributors under the MIT license

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
0.14.0 92 5/14/2024
0.13.0 98 5/6/2024
0.12.0 106 4/2/2024
0.11.0 134 2/18/2024
0.10.0 157 2/5/2024
0.9.0 87 2/1/2024
0.8.5 79 1/31/2024
0.8.4 111 1/29/2024
0.8.3 86 1/26/2024
0.8.2 136 1/21/2024
0.8.1 101 1/20/2024
0.8.0 139 1/15/2024
0.7.0 185 11/27/2023
0.6.0 125 11/21/2023
0.5.2 138 10/29/2023
0.5.1 119 10/28/2023
0.5.0 131 10/28/2023
0.4.0 146 10/26/2023
0.3.3 117 10/3/2023
0.3.2 114 9/30/2023
0.3.0 110 9/29/2023
0.2.1 120 9/24/2023
0.2.0 116 9/21/2023
0.0.10 140 8/27/2023