DEV Community

Cover image for How to pass environment variables to a Rust WASM application like Yew, Dioxus and Leptos as a TypeScript Developer

How to pass environment variables to a Rust WASM application like Yew, Dioxus and Leptos as a TypeScript Developer

Jose on July 10, 2023

Hello TypeStaceans! Here's a step by step process in how you can pass environment variables to a Rust WASM application framework using Yew, Dioxus...
Collapse
 
gekh profile image
German Khokhlov

Easier way is to use inline env vars:

API_URL="http://127.0.0.1:9000" dx serve --port 8008
Enter fullscreen mode Exit fullscreen mode

and in code:

let url = env!("API_URL");
Enter fullscreen mode Exit fullscreen mode

docs: doc.rust-lang.org/std/macro.env.html

Collapse
 
askrodney profile image
Rodney Lab

Thanks for putting this together Jose, it was super useful.