Introducing Fable.Remoting: Automated Type-Safe Client-Server Communication for Fable Apps

“Show me the code!”

Project structure

Update (23–10–2017):

  • Fable.Remoting.Suave now works on netcore2.0
  • Giraffe is now also supported, package Fable.Remoting.Giraffe

Building the Server side

.NET Core 2.0

dotnet new console -lang F#
dotnet add package Fable.Remoting.Suave

Because the library already depends on Suave and Newtonsoft.Json, you don’t have to intall anything else and you are good to go

Sharing code

Implementing 'IServer'

Client App

Setting up the client app

dotnet new --install "Fable.Template::*"
cd Client
dotnet new fable
yarn install
dotnet restore
dotnet fable npm-run start

Installing a library on the client

".paket/paket.exe" add nuget Fable.Remoting.Client project Client.fsproj

Make sure Fable.Core and dotnet-fable have matching versions and that they are both 1.0.7 or newer

dotnet restore --no-cache

Reference the shared types from server

<Compile Include="../App/SharedTypes.fs" />

Making Http Request from Client to Server

This section applies generally when working with client-server apps with a webpack developement server and is not specific when using Fable.Remoting


Webpack proxy to the rescue!

Creating the IServer proxy from the client


Special thanks to Alfonso Garcia-Caro , the author of Fable

The End



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store