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.
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
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.WorkersAI features
Summaries, chat and embeddings from Workers AI models, or from other providers through AI Gateway.
Runtime.WorkersAIProvider Runtime.AIGatewayProviderData and files
Key-value data in KV, SQL in D1 and files in R2.
Runtime.WorkersBackground work
Queues and Workflows for jobs that run after the response goes out.
Runtime.WorkersSandboxes and containers
Isolated sandboxes for untrusted code, and Linux containers beside your Worker.
Runtime.Sandbox Runtime.ContainersAccount setup
Create D1 databases and R2 buckets and upload Workers from an F# program, through Cloudflare's REST API.
Management.Storage Management.ComputeThe 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.