ReScript WebAPI
ReScript bindings for everything you need in the browser.
Installation
Install the package using your favorite package manager:
npm i @rescript/webapi@experimental
bun i @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
let location = window.location;
let href = location.href;
location.reload();
export { location, href,}