StarFederation.Datastar
0.22.0-alpha.171
This is a prerelease version of StarFederation.Datastar.
There is a newer prerelease version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package StarFederation.Datastar --version 0.22.0-alpha.171
NuGet\Install-Package StarFederation.Datastar -Version 0.22.0-alpha.171
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="StarFederation.Datastar" Version="0.22.0-alpha.171" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="StarFederation.Datastar" Version="0.22.0-alpha.171" />
<PackageReference Include="StarFederation.Datastar" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add StarFederation.Datastar --version 0.22.0-alpha.171
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: StarFederation.Datastar, 0.22.0-alpha.171"
#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.
#addin nuget:?package=StarFederation.Datastar&version=0.22.0-alpha.171&prerelease
#tool nuget:?package=StarFederation.Datastar&version=0.22.0-alpha.171&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Datastar + dotnet
Real-time Hypermedia first Library and Framework for dotnet
HTML Frontend
<html lang="en">
<head>
<script type="module" defer src="https://cdn.jsdelivr.net/gh/starfederation/datastar/bundles/datastar.js"></script>
<title>D* Demo</title>
</head>
<body>
<main class="container" id="main" data-signals="{'input':'','output':''}">
<button data-on-click="sse('/displayDate')">Display Date</button>
<div id="target"></div>
<input type="text" placeholder="input:" data-bind-input /><br />
<span data-text="output.value"></span>
<button data-on-click="sse('/changeOutput',{method:'post'})">Change Output</button>
</main>
</body>
</html>
C# Backend
using StarFederation.Datastar;
using StarFederation.Datastar.DependencyInjection;
using System.Text.Json;
using System.Text.Json.Serialization;
...
// define your signals
public record DatastarSignals : ISignals
{
[JsonPropertyName("input")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Input { get; init; } = null;
[JsonPropertyName("output")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? Output { get; init; } = null;
public string Serialize() => JsonSerializer.Serialize(this);
}
...
// add as an ASP Service
// allows injection of IServerSentEventService, to respond to a request with a Datastar friendly ServerSentEvent
// and ISignals, to read the signals sent by the client
builder.Services.AddDatastar<DatastarSignals>();
...
app.UseStaticFiles();
// add endpoints
app.MapGet("/displayDate", async (IServerSentEventService sse) =>
{
string today = DateTime.Now.ToString("%y-%M-%d %h:%m:%s");
await sse.MergeFragments($"""<div id='target'><span id='date'><b>{today}</b><button data-on-click="sse('/removeDate')">Remove</button></span></div>""");
});
app.MapGet("/removeDate", async (IServerSentEventService sse) => { await sse.RemoveFragments("#date"); });
app.MapPost("/changeOutput", async (IServerSentEventService sse, ISignals signals) =>
{
DatastarSignals dsSignals = (signals as DatastarSignals) ?? throw new InvalidCastException("Unknown ISignals passed");
DatastarSignals newSignals = new() { Output = $"Your Input: {dsSignals.Input}" };
await sse.MergeSignals(newSignals);
});
Product | Versions 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 is compatible. 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 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 is compatible. 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. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net6.0
- FSharp.Core (>= 9.0.100)
-
net7.0
- FSharp.Core (>= 9.0.100)
-
net8.0
- FSharp.Core (>= 9.0.100)
-
net9.0
- FSharp.Core (>= 9.0.100)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on StarFederation.Datastar:
Package | Downloads |
---|---|
Falco.Datastar
Datastar Bindings for the Falco web toolkit. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-beta.5 | 281 | 4/1/2025 |
1.0.0-beta.4 | 600 | 3/4/2025 |
1.0.0-beta.3 | 104 | 2/13/2025 |
1.0.0-beta.2 | 81 | 2/10/2025 |
1.0.0-alpha.23 | 75 | 2/4/2025 |
0.22.0-alpha.171 | 89 | 12/23/2024 |