Skip to content

Saturn in SAFE

Saturn is a web development library written in F# which allows you to easily create both server-side MVC applications as well as web APIs. It runs on top of two other components:

  • Giraffe, an F#-specific library for writing functional-first web applications.
  • Microsoft's ASP.NET Core.

Saturn, via Giraffe, provides very good integration with other ASP.NET Core components such as authentication.

Many of Saturn's components and concepts will seem familiar to those of us with experience of other web frameworks such as Ruby on Rails, Python’s Django or especially Elixir's Phoenix.

How does Saturn integrate with SAFE?

Saturn provides the ability to drive your SAFE applications from the server. It enables:

  • Routing and hosting of your server-side APIs through a set of simple-to-use abstractions.
  • Hosting of your client-side assets, such as HTML, CSS and JavaScript generated by Fable.
  • Other cross cutting concerns e.g. authentication etc.

It also integrates with SAFE to allow seamless sharing of types and functions, since Fable will convert most F# into JavaScript. In addition, you can seamless transport data between client and server using either the Fable.JSON or Fable.Remoting libraries, both of which have support for Saturn. You can read more about this here.

flowchart TB outputs>JSON, HTML etc.] subgraph host[.NET Core Host] saturn[Saturn - Routers, Controllers etc.] giraffe[Giraffe - Core F# abstractions] aspnet[ASP.NET Core - HTTP Context etc.] kestrel[Kestrel - Web Server] saturn --- giraffe --- aspnet --- kestrel end data[(Transactional Data e.g. SQL)] content>Static Content e.g. HTML, CSS, JavaScript] outputs -- serves --- host kestrel -- reads --- data kestrel -- reads --- content

Learn more about Saturn here.