Welcome to the new Golem Cloud Docs! 👋


Scala 2 can be used to build WASM components through Scala.js and componentize.js (opens in a new tab)


componentize.js currently does not implement the JS Event Loop. So, if the code generated by Scala.js uses functions like setTimeout the componentization won't work

Scala 3 is currently not supported

Before starting, make sure you have the latest Rust version installed and have cargo in the path. The recommended way to do so is using https://rustup.rs (opens in a new tab):

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
rustup install stable && rustup default stable

Then install the golem-scalajs-wit-bindgen CLI tool, which allows to generate Scala.js bindings from WIT files:

cargo install golem-scalajs-wit-bindgen

You will also need to have npm installed, you can check instructions here (opens in a new tab).

The easiest way to get started once the tooling is installed is to use the golem-cli new command as described in the Quickstart, for example:

golem-cli new --example scala2-shopping-cart --component-name my-shopping-cart

Building the component

Creating the Golem component is just running:

sbt component

The output is target/dist/component-name.wasm and it is ready to be uploaded to Golem Cloud. (the output file's name depends on the project!)