Server-side reactivity

What’s the F# story on server-side reactivity?

By that I mean, something like FRP on the server. For example, consider a TodoMVC app. You have the app open in two browsers (possibly in different computers). You add a todo in one browser, and the other browser instantly (without refresh) updates its view with the new todo.

Implementing this would require a websocket connection, that funnels server-side DB updates to the frontend (react?) of all connected clients. What .net/F# frameworks exist that do this? Both in Fable and Wasm (eg: via Bolero) land?

This is something I enjoyed using when I was writing full-stack apps in Haskell (eg: Cerveau), and it would be amazing to be able to do it in F# as well.

That’s a great question! Server-side reactivity in F# is indeed possible and there are a few frameworks that can help you achieve this:

Saturn: Saturn is a modern web framework for F# that implements the server-side MVC pattern. It’s inspired by Elixir’s Phoenix and provides a functional-first approach to web programming. Saturn can handle WebSocket connections and update connected clients in real-time.

Bolero: Bolero is a framework for building web applications using F# and WebAssembly. It supports both client-side and server-side hosting models3. In server-side mode, Bolero uses SignalR to push updates from the server to the client, similar to what you described.

Fable: While Fable is primarily a compiler that translates F# to JavaScript, it also supports server-side rendering (SSR) with Elmish. This allows you to render your views on the server and then hydrate them on the client side.

These frameworks should give you the server-side reactivity you’re looking for, similar to what you experienced with Haskell’s Cerveau.

Best regards,
Elena
TellCulvers