clojurescript

Fabio Francisco 2025-10-17T15:45:58.192029Z

Hi guys, I have a question regarding configuration. I don't have that much experience with CLJS, I am mainly a backend developer, and with that said, I usually use Aero for loading environment specific configs is that something we could do in CLJS? Just use Aero? Or is there another way to use per environment configs in CLJS?

p-himik 2025-10-17T16:17:04.336939Z

It depends on what exactly you want to configure and when. It doesn't matter in CLJ because compile-time and run-time are in the same process and are inseparable. In CLJS, compilation is a separate step that usually happens on a completely different machine, likely in a different environment altogether. If I need for the CLJS compilation to produce different results based on some explicitly set flags (I deliberately avoid env vars here because it's easy to accidentally misuse them), I use https://shadow-cljs.github.io/docs/UsersGuide.html#closure-defines in a build config. Convenient since you can override them via CLI. If I need for some run-time values to be fetched from the environment, there are two main ways to do them: • Embed the values in some artifact that's generated at run time (e.g. if you generate index.html from Hiccup, you can easily embed values inside the <meta> tags or e.g. as a serialized transit doc inside some <script> with a custom type) • Fetch via js/fetch or any other mechanism you use to communicate with your server

Fabio Francisco 2025-10-17T16:41:55.126499Z

I was thinking about configuring for instance different API urls and such, so that in prod we call a different url than in dev, that's a simple example

Fabio Francisco 2025-10-17T16:42:12.809619Z

I know that in node you can use project.env which uses env variables ofc

p-himik 2025-10-17T17:45:00.378349Z

"Dev" is an overloaded term. If it's about local development, the value can be set during compilation. If it's about some remote machine that uses the same deployment artifact, the value can only be retrieved at run time.

👍 1
Fabio Francisco 2025-10-17T17:47:10.783529Z

thx!