Getting started
How to start in 60 seconds
Requirements:
dotnet
SDK 6.0 - link
Template
The easiest way to get started is to use the provided template:
- Install the
dotnet
template withdotnet new -i Saturn.Template
- Create a new folder and move into it -
mkdir SaturnSample && cd SaturnSample
- Create a new Saturn application -
dotnet new saturn -lang F#
- Install all necessary dev tools -
dotnet tool restore
- Create a new controller with
dotnet saturn gen Book Books id:string title:string author:string
- Run migrations that will create the database and Books table (as for now, the generator is using only SQLite DB) -
dotnet saturn migration
- Open the folder in your favourite editor (VSCode) and insert the line (
forward "/books" Books.Controller.resource
) intobrowserRouter
inRouter.fs
file - Start the application by running
dotnet watch --project ./src/SaturnSample/
from the root of the solution. This will start the application in watch mode (automatic recompilation on changes - documentation link) and open your browser on http://localhost:8085 which should display the index page. - Go to http://localhost:8085/books to see the generated view. All buttons should be working; you can add new entries, and remove or edit old ones.
Hello World
If you want to start from scratch with a minimal Saturn webserver:
- Create a new F# Project (for example with
dotnet new console -lang F#
) - Add the
Saturn
NuGet Package
open Saturn
open Giraffe
let app = application {
use_router (text "Hello World from Saturn")
}
run app
If you compile and run this application, it will unconditionally return the text regardless of the path.
From here on out you can add routers, controllers and views.
Deep Dive
To get a better understanding of Saturn and the whole SAFE Stack you can look at the SAFE-Dojo.