Frank.Datastar 6.5.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package Frank.Datastar --version 6.5.0
                    
NuGet\Install-Package Frank.Datastar -Version 6.5.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="Frank.Datastar" Version="6.5.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Frank.Datastar" Version="6.5.0" />
                    
Directory.Packages.props
<PackageReference Include="Frank.Datastar" />
                    
Project file
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 Frank.Datastar --version 6.5.0
                    
#r "nuget: Frank.Datastar, 6.5.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.
#:package Frank.Datastar@6.5.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Frank.Datastar&version=6.5.0
                    
Install as a Cake Addin
#tool nuget:?package=Frank.Datastar&version=6.5.0
                    
Install as a Cake Tool

Frank

NuGet Version GitHub Release Date Build status

F# computation expressions, or builders, for configuring the Microsoft.AspNetCore.Hosting.IWebHostBuilder and defining routes for HTTP resources using Microsoft.AspNetCore.Routing.

This project was inspired by @filipw's Building Microservices with ASP.NET Core (without MVC).


Packages

Package Description NuGet
Frank Core computation expressions for WebHost and routing NuGet
Frank.Datastar Datastar SSE integration for reactive hypermedia NuGet
Frank.Analyzers F# Analyzers for compile-time error detection NuGet

Features

  • WebHostBuilder - computation expression for configuring WebHost
  • ResourceBuilder - computation expression for configuring resources (routing)
  • No pre-defined view engine - use your preferred view engine implementation, e.g. Falco.Markup, Oxpecker.ViewEngine, or Hox
  • Easy extensibility - just extend the Builder with your own methods!

Basic Example

module Program

open System.IO
open Microsoft.AspNetCore.Builder
open Microsoft.AspNetCore.Http
open Microsoft.AspNetCore.Routing
open Microsoft.AspNetCore.Routing.Internal
open Microsoft.Extensions.DependencyInjection
open Microsoft.Extensions.Logging
open Frank
open Frank.Builder

let home =
    resource "/" {
        name "Home"

        get (fun (ctx:HttpContext) ->
            ctx.Response.WriteAsync("Welcome!"))
    }

[<EntryPoint>]
let main args =
    webHost args {
        useDefaults

        logging (fun options-> options.AddConsole().AddDebug())

        plugWhen isDevelopment DeveloperExceptionPageExtensions.UseDeveloperExceptionPage
        plugWhenNot isDevelopment HstsBuilderExtensions.UseHsts

        plugBeforeRouting HttpsPolicyBuilderExtensions.UseHttpsRedirection
        plugBeforeRouting StaticFileExtensions.UseStaticFiles

        resource home
    }

    0

Middleware Pipeline

Frank provides two middleware operations with different positions in the ASP.NET Core pipeline:

Request → plugBeforeRouting → UseRouting → plug → Endpoints → Response

plugBeforeRouting

Use for middleware that must run before routing decisions are made:

  • HttpsRedirection - redirect before routing
  • StaticFiles - serve static files without routing overhead
  • ResponseCompression - compress all responses
  • ResponseCaching - cache before routing
webHost args {
    plugBeforeRouting HttpsPolicyBuilderExtensions.UseHttpsRedirection
    plugBeforeRouting StaticFileExtensions.UseStaticFiles
    resource myResource
}

plug

Use for middleware that needs routing information (e.g., the matched endpoint):

  • Authentication - may need endpoint metadata
  • Authorization - requires endpoint to check policies
  • CORS - may use endpoint-specific policies
webHost args {
    plug AuthenticationBuilderExtensions.UseAuthentication
    plug AuthorizationAppBuilderExtensions.UseAuthorization
    resource protectedResource
}

Conditional Middleware

Both plugWhen and plugWhenNot run in the plug position (after routing):

webHost args {
    plugWhen isDevelopment DeveloperExceptionPageExtensions.UseDeveloperExceptionPage
    plugWhenNot isDevelopment HstsBuilderExtensions.UseHsts
    resource myResource
}

Frank.Datastar

Frank.Datastar provides seamless integration with Datastar, enabling reactive hypermedia applications using Server-Sent Events (SSE).

Installation

dotnet add package Frank.Datastar

Example

open Frank.Builder
open Frank.Datastar

let updates =
    resource "/updates" {
        name "Updates"

        datastar (fun ctx -> task {
            // SSE stream starts automatically
            do! Datastar.patchElements "<div id='status'>Loading...</div>" ctx
            do! Task.Delay(500)
            do! Datastar.patchElements "<div id='status'>Complete!</div>" ctx
        })
    }

// With explicit HTTP method
let submit =
    resource "/submit" {
        name "Submit"

        datastar HttpMethods.Post (fun ctx -> task {
            let! signals = Datastar.tryReadSignals<FormData> ctx
            match signals with
            | ValueSome data ->
                do! Datastar.patchElements $"<div id='result'>Received: {data.Name}</div>" ctx
            | ValueNone ->
                do! Datastar.patchElements "<div id='error'>Invalid data</div>" ctx
        })
    }

Available Operations

  • Datastar.patchElements - Update HTML elements in the DOM
  • Datastar.patchSignals - Update client-side signals
  • Datastar.removeElement - Remove elements by CSS selector
  • Datastar.executeScript - Execute JavaScript on the client
  • Datastar.tryReadSignals<'T> - Read and deserialize signals from request

Each operation also has a WithOptions variant for advanced customization.


Frank.Analyzers

Frank.Analyzers provides compile-time static analysis to catch common mistakes in Frank applications.

Installation

dotnet add package Frank.Analyzers

Available Analyzers

FRANK001: Duplicate HTTP Handler Detection

Detects when multiple handlers for the same HTTP method are defined on a single resource. Only the last handler would be used at runtime, so this is almost always a mistake.

// This will produce a warning:
resource "/example" {
    name "Example"
    get (fun ctx -> ctx.Response.WriteAsync("First"))   // Warning: FRANK001
    get (fun ctx -> ctx.Response.WriteAsync("Second"))  // This one takes effect
}

IDE Integration

Frank.Analyzers works with:

  • Ionide (VS Code)
  • Visual Studio with F# support
  • JetBrains Rider

Warnings appear inline as you type, helping catch issues before you even compile.


Building

Make sure the following requirements are installed in your system:

dotnet build

Sample Applications

The sample/ directory contains several example applications:

Sample Description
Sample Basic Frank application
Frank.Datastar.Basic Datastar integration with minimal HTML
Frank.Datastar.Hox Datastar with Hox view engine
Frank.Datastar.Oxpecker Datastar with Oxpecker.ViewEngine
Frank.Falco Frank with Falco.Markup
Frank.Giraffe Frank with Giraffe.ViewEngine
Frank.Oxpecker Frank with Oxpecker.ViewEngine

License

Apache 2.0

Product 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 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 is compatible.  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.

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
7.2.0 93 2/10/2026
7.1.0 111 2/7/2026
7.0.0-build.0 48 2/6/2026
6.5.0 118 2/5/2026
6.4.1 112 2/4/2026
6.4.1-build.0 50 2/4/2026
6.4.0 102 2/2/2026
6.4.0-build.0 49 2/2/2026

### New in 6.5.0 (Released 2026-02-04)
- Fixed middleware pipeline ordering: `plug` middleware now runs after `UseRouting` and before `UseEndpoints`
- Added `plugBeforeRouting` for middleware that must run before routing (e.g., StaticFiles, HttpsRedirection)
- Added middleware ordering tests
### New in 6.4.1 (Released 2026-02-04)
- Add Frank.Analyzers to assist with validating resource definitions
- Added additional Frank.Datastar helpers to use more StarFederation.Datastar options
### New in 6.4.0 (Released 2026-02-02)
- Updated to target net8.0, net9.0, and net10.0
- Add Frank.Datastar
- Updated samples and added samples for Frank.Datastar
### New in 6.3.0 (Released 2025-03-14)
- Updated to target net8.0 and net9.0
- Updated examples
### New in 6.2.0 (Released 2020-11-18)
- Updated samples
### New in 6.1.0 (Released 2020-06-11)
- Encapsulate `IHostBuilder` and expose option to use web builder defaults with `useDefaults`.
- Server application can now be simply a standard console application. See [samples](https://github.com/frank-fs/frank/tree/master/sample).
### New in 6.0.0 (Released 2020-06-02)
- Update to .NET Core 3.1
- Use Endpoint Routing
- Pave the way for built-in generation of Open API spec
### New in 5.0.0 (Released 2019-01-05)
- Starting over based on ASP.NET Core Routing and Hosting
- New MIT license
- Computation expression for configuring IWebHostBuilder
- Computation expression for specifying HTTP resources
- Sample using simple ASP.NET Core web application
- Sample using standard Giraffe template web application
### New in 4.0.0 - (Released 2018/03/27)
- Update to .NETStandard 2.0 and .NET 4.6.1
- Now more easily used with Azure Functions or ASP.NET Core
### New in 3.1.1 - (Released 2014/12/07)
- Use FSharp.Core from NuGet
### New in 3.1.0 - (Released 2014/10/13)
- Remove dependency on F#x
- Signatures remain equivalent, but some type aliases have been removed.
### New in 3.0.19 - (Released 2014/10/13)
- Merge all implementations into one file and add .fsi signature
### New in 3.0.18 - (Released 2014/10/12)
- Use Paket for package management
- FSharp.Core 4.3.1.0
- NOTE: Jumped to 3.0.18 due to bad build script configuration
### New in 3.0.0 - (Released 2014/05/24)
- Updated dependencies to Web API 2.1 and .NET 4.5
### New in 2.0.3 - (Released 2014/02/07)
- Add SourceLink to link to GitHub sources (courtesy Cameron Taggart).
### New in 2.0.2 - (Released 2014/01/26)
- Remove FSharp.Core.3 as a package dependency.
### New in 2.0.0 - (Released 2014/01/07)
- Generate documentation with every release
- Fix a minor bug in routing (leading '/' was not stripped)
- Reference FSharp.Core.3 NuGet package
- Release assembly rather than current source packages:
- FSharp.Net.Http
- FSharp.Web.Http
- Frank
- Adopt the FSharp.ProjectScaffold structure
### New in 1.1.1 - (Released 2014/01/01)
- Correct spacing and specify additional types in HttpContent extensions.
### New in 1.1.0 - (Released 2014/01/01)
- Remove descriptor-based implementation.
### New in 1.0.2 - (Released 2013/12/10)
- Restore Frank dependency on FSharp.Web.Http. Otherwise, devs will have to create their own routing mechanisms. A better solution is on its way.
### New in 1.0.1 - (Released 2013/12/10)
- Change Web API dependency to Microsoft.AspNet.WebApi.Core.
### New in 1.0.0 - (Released 2013/12/10)
- First official release.
- Use an Option type for empty content.