In Luma the
mage/url module is used prepend an URL path with the current store base URL.
With Hyvä it is much simpler: the
window.BASE_URL variable can be used.
For regular requests, usetemplate literal version
The above is the equvalent to what the Luma
urlBuilder.build() method does.
A alternative option is to render the base URL with PHP:
There is no "better" or "worse" way to do this.
If you need to add the store code to the request path, for example for Ajax requests, use