pub fn var(name: &str) -> Result<Var, CfError>Expand description
Access a plaintext environment variable by name.
Shorthand for cf::env().var(name).cf()?. Variables are set in the
[vars] section of wrangler.toml — they are not encrypted.
The returned value implements Display / ToString.
§Errors
Returns CfError if the variable is missing.
§Example
ⓘ
use dioxus_cloudflare::prelude::*;
#[server]
pub async fn get_env() -> Result<String, ServerFnError> {
let env = cf::var("ENVIRONMENT")?.to_string();
Ok(env)
}