Main Application Templates
The three main WebSharper application types are:
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.
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.
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:
Library - a simple WebSharper library. Annotated code is compiled to JavaScript, and can then be used from any application project.
Extension - defines the interface to an existing JavaScript library using a convenient declarative F# syntax.
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.
Owin-hosted Site - a client-server application with Owin hosting.
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
Capabilities
This table summarizes the capabilities of the available application/helper project templates:
Template | dotnet new |
C# available | Is Sitelet? | Client | Server | Remote |
---|---|---|---|---|---|---|
Applications | ||||||
Client-Server App ASP.NET / Core |
websharper-web |
|||||
Client-Server App Hosted via OWIN or Suave |
||||||
HTML App | websharper-html |
|||||
Single-Page App ASP.NET / Core |
websharper-spa |
|||||
Single-Page App Packaging for mobile |
||||||
Helpers | ||||||
Library | websharper-lib |
|||||
Extension |
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
andScripts/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.
- Same as
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.