Skip to content

Getting started

NPM Version

Installation

Install the package using your favorite package manager:

npm i -D @rescript/webapi@experimental

and add @rescript/webapi to your rescript.json:

{
"bs-dependencies": [
"@rescript/webapi",
],
"bsc-flags": [
"-open WebAPI.Global"
]
}

Usage

After installing the package , you can use bindings for the various Web APIs as defined in MDN.

// Note that this only works when you added the `-open WebAPI.Global` bsc flag.
let location = window.location
// Access properties using `.`
let href = location.href
// Invoke methods using the `->TypeModule.method`
location->Location.reload