United Kingdom: +44 (0)208 088 8978

Introducing the SAFE stack

We're hiring Software Developers

Click here to find out more


Throughout this week, we've published a series of articles contributed by some well-known people within the F# community focused on web and cloud programming. Today, we're announcing the launch of the SAFE stack initiative, which brings all of the elements together as a cohesive story:

  • Saturn model for server-side web programming
  • Azure for cloud-based systems
  • Fable for Javascript-enabled applications
  • Elmish for an easy-to-understand UI programming model

In collaboration with our partners, we've today launched the SAFE website, which we are hoping becomes the go-to place for people developing functional-first, cloud-ready web applications.

What is SAFE

It's important to understand that SAFE in itself is not a stack that forces you down the route of using the specific technologies named above. Instead, think of them as a starting place to refer to when you're considering an end-to-end solution in F#; we suggest that the key behaviours in SAFE web technologies should include:

  • Embraces functional programming paradigms
  • Excellent support for F#
  • Readily deployable to a cloud provider
  • Adheres to common standards where possible

Here's a little more detail on this philosophy for each component in the stack.

The Saturn Model

It's key to understand that whilst we are fans of Saturn, we believe that there's also room here for other F#-friendly web programming models. As mentioned in the web programming article of this series, this also includes "dropping down" to Giraffe, Freya and WebSharper.


Whilst we at Compositional IT are big fans of Azure and recommend it as our default cloud provider for customer solutions that require scalable, flexible and easy-to-use services, we know that not everyone feels this way. As such, there's no reason with the SAFE stack can't work equally well on Amazon Web Services (AWS) or Google Cloud Platform (GCP).


Fable provides a superb experience for F#-to-Javascript transpilation in a flexible manner, as well as an experience that "plays nicely" with both the .NET and Javascript ecosystems. However, there are other solutions out there, such as WebSharper, which offers an all-in-one F# solution for F# web applications, and you should certainly investigate such options. Nonetheless, Fable remains our default recommendation for F#-and-Javascript-ecosystem integration.


Elmish provides an excellent option for a UI model that supports some of the core principles of functional programming, such as immutability and expression-based programming, whilst taking full advantage of many of F#'s language features such as discriminated unions and pattern matching. There are other UI models available such as (again) WebSharper's Piglets and Formlets models etc., that you

SAFE isn't an "all-or-nothing" choice

SAFE isn't a prescriptive solution that forces you to go "all in" either. Here are some alternative application architectures that utilise a variety of elements of the SAFE stack in different ways.

Prototypical SAFE stack

Here's a typical SAFE stack using all the "default" technology set.

An example of this is available on the SAFE github repository with the SAFE Bookstore app.

Alternative SAFE stack

Here's an alternative version of the SAFE stack that uses some other technologies for the same purposes as the original stack, such as AWS for hosting, and Giraffe for the server-side web stack - this is also totally cool.

Partial SAFE stack

Here's a partial implementation of the SAFE stack, which uses F# for the server side, but uses conventional a Typescript + AngularJS combination for the client side.

On-Premise partial SAFE stack

This is another partial implementation of the SAFE stack, this time using an on-premise installation of the stack, possibly using IIS for hosting the web application, whilst using on-premise database and messaging systems.


Finally, let's look at how we can use the SAFE stack for a cut-down stack - this time just an HTTP-enabled API running Saturn, which returns data sourced from Document DB (perhaps along with data retrieved from other sources, for example via a type provider). We're using Fable here to create F# stored procedures in Cosmos DB, which are normally written in Javascript.

SAFE Mobile

By adding React Native into the mix, there's nothing to stop you creating mobile applications using the SAFE stack. There's an example of this with the SAFE Nightwatch sample, too!

What's next

It's early days for SAFE, but we feel that this is a particuarly sweet spot within the F# world. We're hopeful that the F# community will come together to collaborate and make the SAFE site the go-to place for someone looking to get up and running with these sorts of applications.

Please do bookmark the official website - we'll be making lots of updates to it in the coming weeks, including adding more documentation and reference applications using alternative stacks. We're also considering doing the following:

  • Creating NuGet metapackages that contain references to all these packages to get you up and running quickly
  • Creating ready-made paket.dependencies + lock files which you can use to get started
  • Simple .NET Core templates for "ready-to-go" solutions, whilst being mindful of avoiding code-bloat that can adversely affect ready-made solutions.

Please, also follow the official safe_stack Twitter account as well for the latest news over the coming weeks. We'd love to hear your feedback - please reach out to us.