Skip to content
0.1.0 MIT licensed

FSharp.CloudEdge

Build intelligent products on Cloudflare with F#.

F# developers deserve a first-class experience for building on Cloudflare. And Cloudflare gets a first-class functional language that can honor its contracts and honor the Fable Compiler's original promise of “JavaScript you can be proud of”.

Cloudflare runs your code at cloud's edge, close to your users, and provides modern, responsive agentic tools. You can start with a free plan that covers 100,000 Worker requests per day. FSharp.CloudEdge makes the full array of Cloudflare products and services available in F#, from dynamic web pages to agentic AI capabilities.

Counter.fsDurable Object
module Counter

open Fable.Core

module Workers = FSharp.CloudEdge.Runtime.Workers
module Runtime = FSharp.CloudEdge.Runtime.Workers.Cloudflare.Workers

type Counter(ctx: Workers.DurableObjectState<obj>, env: obj) =
    inherit Runtime.DurableObject<obj, obj>(ctx, env)

    interface Runtime.DurableObject.IFetchHandler with
        member _.fetch _ =
            async {
                let! current = ctx.storage.get<float>("count") |> Async.AwaitPromise
                let count = Option.defaultValue 0. current + 1.
                do! ctx.storage.put("count", count) |> Async.AwaitPromise
                return Workers.Exports.Response.json {| count = count |}
            }
            |> Async.StartAsPromise
            |> U2.Case1
Compiles against FSharp.CloudEdge 0.1.0.

Building Blocks

Each block is a Cloudflare service with F# bindings in this library, with the free-plan allowance where Cloudflare offers one.

Real-time rooms

Chat rooms and live dashboards, each room a Durable Object with its own storage and WebSockets.

Runtime.Workers
Free: 100,000 requests a day

AI features

Summaries, chat and embeddings from Workers AI models, or from other providers through AI Gateway.

Runtime.WorkersAIProvider Runtime.AIGatewayProvider
Free: 10,000 Neurons a day

Data and files

Key-value data in KV, SQL in D1 and files in R2.

Runtime.Workers
Free: 5 GB in D1, 10 GB in R2

Agents

Stateful agents with tools, schedules and MCP servers.

Runtime.Agents Runtime.Think

Background work

Queues and Workflows for jobs that run after the response goes out.

Runtime.Workers
Free: 100,000 Workflow requests a day

Sandboxes and containers

Isolated sandboxes for untrusted code, and Linux containers beside your Worker.

Runtime.Sandbox Runtime.Containers

Account setup

Create D1 databases and R2 buckets and upload Workers from an F# program, through Cloudflare's REST API.

Management.Storage Management.Compute

The runtime bindings are generated by Xantham from Cloudflare's own TypeScript declarations, and the account-setup clients by Hawaii from Cloudflare's OpenAPI document. How the library is made.