Skip to content

websharper

Websharper super power with Vars

#WebSharper’s super power with Vars Using WebSharper allows you to develop both the client side and the server side of a web application in C# or F#, with client to server communication abstracted as RPC calls. There’s no need to handle low-level concerns like XMLHttpRequest or data serialisation. There’s great Javascript interoperability of course, allowing to use javascript libraries from your F# code. But still, what I enjoy most when developing a WebSharper app is its reactive layer built on Vars and Views.

Manipulating javascript objects in FSharp with WebSharper

In a WebSharper app I’m using Bootstrap tooltips, and those need to be initialised explicitly. As shown in the doc this is easily done. For example this code will make the tooltip work as expected for the element with id elementId, so that hovering that element will trigger the tooltip to be shown: var el = document.getElementById(elementId) new bootstrap.Tooltip(el) However, in my case, the element for which a tooltip should be shown is dynamically added and removed from the document following user actions.

Websharper compilation problem after dotnet update

If you encounter problems compiling your WebSharper project after an update of your dotnet installation, you might have to restart the service wsfscservice. Under linux you can simply issue the command pkill wsfscservice. wsfscservice is used to speed up repeated compilation. As explained by Jand42:it uses AssemblyLoadContext for WS macros/offline site generator, but F# compiler part can sadly lock some dlls for TPs and it seems SDK update messes with it too.

Websharper Proxy Project

WebSharper lets you bring your FSharp code to the client-side. For types in your WebSharper project to be used at both server and client sides, you annotate them with [<JavaScript>]. For types that were compiled without WebSharper, you need to define a proxy type, which will be compiled to javascript and be used in place of the compiled type. This is done easily, as this example from the official documentation shows:

Passwordless Login Sending Login Mail Websharper

This post is part of series starting here. Sending the mail Sending the mail is not hard, but will show how code running at the client side can call RPC functions provided by the server. These calls are totally transparent. For the login page, we add an endpoint: | [<EndPoint "/l">] Login and map it to a function all as seen earlier: Application.MultiPage (fun ctx endpoint -> match endpoint with | EndPoint.

Passwordless Login With Websharper

Intro I had the need recently to provide some admin access to a web application, but adding password management in that application was not worth the trouble. It was much easier to allow users to request a authentication link by email, as this post will show. The web app is dveloped in WebSharper. If you’re a F# developed, you should really check it out! I like that I can develop client and server in one integrated code base, all in F#.