Build full-stack web apps. Stay in F#.
Build reactive UIs, call server functions directly, and share types across your application - all with the power of F# and .NET.
Trusted by fast-growing companies around the world
How it works
Write your app once in F#, C# or OCaml. One dotnet build turns it into a native server, a JavaScript client and the typed contract between them.
type Product = { Name: string; Price: float }[<Rpc>] let Search (q: string) = async { return Db.products |> Array.filter (fun p -> p.Name.Contains q) }[<JavaScript>] let SearchBox () = SearchForm().OnSearch(fun e -> async { let! found = Search e.Vars.Query.Value results.Value <- found } |> Async.Start)
public record Product(string Name, double Price);[Remote] public static Task<Product[]> Search(string q) => Db.Products.Where(p => p.Name.Contains(q)) .ToArrayAsync();[JavaScript] public static Doc SearchBox() => new SearchForm().OnSearch(async e => results.Value = await Search(e.Vars.Query.Value)) .Doc();
type product = { name : string; price : float }let[@rpc] search (q : string) : product list = List.filter (fun p -> contains p.name q) (Db.products ())let search_box () = let query = Var.create "" and results = Var.create [] in div [] [ Doc.input [] query; button [ on.click (fun _ _ -> results := search !query) ] [ text "Search" ] ]
WebSharper compiler
$ dotnet build
- ✓Server: assembly, remote endpoints
- ✓Client: ES modules, typed proxies
- ✓JSON for the shared types
- ✓Routes, .d.ts, source maps
Server ASP.NET Core · OCaml
Pages, typed routes and the Search endpoint, in a host you already know how to run.
Browser JavaScript
Readable ES modules that call the server like a local function, with TypeScript declarations and source maps.
One file, both tiers
Mark what runs where. The compiler runs the server part as .NET, the client part as JavaScript, and writes everything in between.
Runs on the server
Search
Native .NET, behind a remote endpoint the compiler adds to your server.
Product on both sides
One record: the same fields, equality and JSON format in .NET and in JavaScript.
type Product = { Name: string; Price: float }[<Rpc>] let Search (q: string) = async { return Db.products |> Array.filter (fun p -> p.Name.Contains q) }[<JavaScript>] let SearchBox () = let results = Var.Create [||] Templates.Main.SearchForm() .OnSearch(fun e -> async { let! found = Search e.Vars.Query.Value results.Value <- found } |> Async.Start) .Results(results.View |> Doc.BindSeqCached ProductItem) .Doc()
Runs in the browser
SearchBox
An ES module that renders the form and updates the list as results arrive.
Search as a call
A typed client proxy: the arguments and the result are serialized for you.
Functional, reactive applications with WebSharper.UI
Bind composite data models to your reactive user interfaces. The flow of reactive values through the code yet concise, readability.
Powerful UI abstractions
Declare full interactive forms in just a few lines of code with WebSharper Forms.
Web Workers without hassle
Write client-side parallel code directly in your code.
The compiler automatically creates the separate trimmed JavaScript file for the web worker.
let worker = new Worker(fun self ->
// This code runs in the worker:
self.OnMessage <- fun e ->
Console.Log(
"Received message from main thread: "
+ string e.Data
)
)
// This code runs in the main thread:
worker.PostMessage("Hello, worker!")
var worker = new Worker("worker.js");
worker.postMessage("Hello, worker!");
self.onmessage = function (e) {
console.log(
"Received message from main thread: "
+ e.data.toString());
}
Fewer seams, not just fewer lines
In a typical full-stack app much of the code at the boundary is glue. WebSharper generates it, so one compiler checks both sides at once, and so does your coding agent's next build.
A typical full-stack app
Two languages, two toolchains, glue at every boundary.
With WebSharper
One project. The compiler writes the boundary.
UI, remote calls and domain in one language
Client code, remote functions and shared types, in F#, C# or OCaml.
1
language and type system
0
hand-written boundary layers
More in the box
A single toolset spanning the server, the client, and the boundary between them.
Sitelets
Strongly-typed routing and content. Endpoints are values, and links are generated and checked by the compiler.
Forms
Declarative, composable web forms with retargetable rendering and validation.
Typed WebSockets
Bidirectional messaging between server and client with automatically serialized messages.
Metaprogramming
Translate calls to specific methods with custom logic, or emit JavaScript generated at compile time.
Client-side testing
A unit-testing framework that is easy to use from .NET and compiles to QUnit tests.
Bindings & npm
Generate typed bindings for JavaScript libraries, or package your .NET code as an npm module with .d.ts files.
The whole stack, at a glance
What you write, what WebSharper does with it, and what you ship.
You write
F#
Unions, records, computation expressions
C#
Records, LINQ, async/await
OCaml experimental
Modules, variants
DSL spec
Generated into F#
WebSharper
One compiler, one typed model of your app
You ship
Server
Native ASP.NET Core or OCaml: pages, routes, auth and your data access.
Typed contract, generated
Browser
Readable ES modules, .d.ts for TypeScript, source maps back to your code.
Get Started
Instant access to the power of WebSharper