Main Application Templates

The three main WebSharper application types are:

  1. Client-Server Application - a full client-server application implemented as a WebSharper sitelet.

    The sitelet uses a dynamic HTML template and placeholders that are instantiated by the sitelet. See the Reactive HTML documentation page for more information on dynamic templating.

    These applications exist in two kinds: a Client-Server Web Application runs as an ASP.NET module, while a Self-Hosted Client-Server Web Application runs as a self-contained executable using an OWIN self-host container.

  2. HTML Site - a multi-page HTML/JavaScript application.

    Like the Client-Server Application, this application also uses sitelets and dynamic HTML to define web pages. However, it creates a set of static HTML and JavaScript files that can be deployed in any HTML container.

    WebSharper mobile web applications can also be created from this template.

  3. Single-Page Application - a single-page HTML/JavaScript application with an HTML page and an F# source file that plugs content into it.

    The easiest way to get started with WebSharper: write a few lines of F#, add a placeholder for it in the HTML, and you are ready to go.

    See the "Your first app in 2 minutes" tab for an example.

The following helper projects are also available:

  1. Library - a simple WebSharper library. Annotated code is compiled to JavaScript, and can then be used from any application project.

  2. Extension - defines the interface to an existing JavaScript library using a convenient declarative F# syntax.

  3. Mobile Application - a single-page application without web hosting and with a readme with instructions about how to wrap the code output in an Apache Cordova application.

  4. Owin-hosted Site - a client-server application with Owin hosting.

  5. Suave-hosted Site - a client-server application with Suave hosting.

.NET Core

Some templates are available for .NET Core/Standard, see Installing WebSharper Templates for .NET Core/Standard


This table summarizes the capabilities of the available application/helper project templates:

Template dotnet new C# available Is Sitelet? Client Server Remote
Client-Server App
ASP.NET / Core
websharper-web X X X X X
Client-Server App
Hosted via OWIN or Suave
HTML App websharper-html X X X X
Single-Page App
ASP.NET / Core
websharper-spa X X X
Single-Page App
Packaging for mobile
Library websharper-lib X
  • Client - Contains code compiled to JavaScript, executing on the client-side.

  • Server - Contains code you deploy for your application, executing on your server-side.

  • Remote - Contains code you from someone else's server, typically through a web service.

MSBuild Project File Configuration

The WebSharper compiler is included in the NuGet packages WebSharper.CSharp and WebSharper.FSharp. The type of project is driven by the Project value in a wsconfig.json file, or the property WebSharperProject in the .csproj/.fsproj. Here are the possible values:

  • Site: for Client-Server Applications.
    • Compiles JavaScript-annotated code;
    • Extracts resources in the folders Content/WebSharper and Scripts/WebSharper.
  • Html: for HTML Applications.
    • Compiles JavaScript-annotated code;
    • Generates HTML files in $(WebSharperHtmlDirectory) and extracts resources in $(WebSharperHtmlDirectory)/Content/WebSharper and $(WebSharperHtmlDirectory)/Scripts/WebSharper.
  • Bundle: for Single-Page Applications.
    • Compiles JavaScript-annotated code;
    • Extracts and concatenates resources (js+css) into the folder Content.
  • BundleOnly: for Single-Page Applications without .NET compilation.
    • Same as Bundle but skips any other build steps not related to producing the js+css output for quick iterative development.
  • Library: for Libraries.
    • Compiles JavaScript-annotated code.
  • InterfaceGenerator: For Extensions.
    • Compiles the classes defined using WIG into an assembly.

The other compilation settings are fully documented here.