/fable-browser

Fable bindings for Browser Web APIs

Primary LanguageF#MIT LicenseMIT

fable-browser

Fable bindings for Browser Web APIs

NuGet Name Description
Nuget Package Fable.Browser.Blob Bindings for the browser Blob API.
Nuget Package Fable.Browser.Dom Bindings for DOM and HTML interfaces
Nuget Package Fable.Browser.Event Bindings for the browser Event interface
Nuget Package Fable.Browser.Performance Bindings for the browser Performance API
Nuget Package Fable.Browser.Url Bindings for the browser Url API
Nuget Package Fable.Browser.WebSocket Bindings for the browser WebSocket API
Nuget Package Fable.Browser.WebRTC Bindings for the browser WebRTC API
Nuget Package Fable.Browser.WebStorage Bindings for the Web Storage API
Nuget Package Fable.Browser.XMLHttpRequest Bindings for the browser XMLHttpRequest API
Nuget Package Fable.Browser.Svg Bindings for the browser Svg API
Nuget Package Fable.Browser.Css Bindings for the browser Css API
Nuget Package Fable.Browser.Worker Bindings for the browser Worker API
Nuget Package Fable.Browser.Geolocation Bindings for the browser Geolocation API
Nuget Package Fable.Browser.Navigator Bindings for the browser Navigator API
Nuget Package Fable.Browser.MediaStream Bindings for the browser MediaStream API
Nuget Package Fable.Browser.MediaRecorder Bindings for the browser MediaRecorder API
Nuget Package Fable.Browser.MediaQueryList Bindings for the browser MediaQueryList API
Nuget Package Fable.Browser.WebGL Bindings for the browser WebGL API

Usage

After installing one of the Nuget packages you can access the API. For that, you only need to open the Browser namespace.

open Browser

let fooEl = document.getElementById("foo")

Note the API values are actually contained in an [<AutoOpen>] module, so if you need to fully qualify the value to avoid name conflicts, use the full module name (same as the Nuget package without Fable. prefix):

let fooEl = Browser.Dom.document.getElementById("foo")

If you need to reference one of the types in the package, open the Browser.Types namespace:

open Browser.Types

let handleClick (ev: MouseEvent) = printfn "click!"

Publishing

If you have rights to publish the packages, the only thing you need to do is to bump the version in the appropriate RELEASE_NOTES file and then run npm run publish. The build script will automatically detect what packages have new versions, update the .fsproj file and push a release. Just make sure:

  • Your Nuget API key is in a FABLE_NUGET_KEY environmental variable
  • The packages you want to publish are listed in the packages list of the Build.fsx script