@rnattochdag Posts What I Use Snippets

ReScript: Adding a third-party library

2021-01-25 • 1 min read

Sometimes we want to include a library that extends our code. To add a third-party library to our ReScript code we use npm as we would in a JavaScript project, but after installing we need to adjust our ReScript configuration to include the new code.

We start by installing the library using npm or yarn. For this example, I'll be using @opendevtools/rescript-telefonnummer.

npm install --save @opendevtools/rescript-telefonnummer

After the installation is complete we need to add the library name in our bsconfig.json in the bs-dependencies array.

// bsconfig.json
"bs-dependencies": [

After saving, the compiler will pick up that a change has been made in the configuration and build the library. We're now ready to start using the library in our code.