env()
Last updated 4/02/2026
Definition
The env() is a function on the
Five
object that lets you read an environment variable from the FIve runtime by name.
Examples
The following functions demonstrate how you can use the
env()
function on the Five
object.
Read an environment value
This code logs the current runtime environment to provide visibility into the development, testing, or produciton environments.
Logs the current environment
const envName = five.env("DEPLOYMENT_MODE");
five.log("Running in environment: ", envName);
Set API endpoint automatically based on environment
This code checks the current environment and sets the API endpoint variable accordingly, so that the application uses the correct backend URL automatically.
Setting API endpoint based on environment
// Read the environment
const envName = five.env("DEPLOYMENT_MODE");
// Set a variable based on the environment
if (envName === "prod") {
five.variable.API_URL = "https://api.myapp.com";
} else {
five.variable.API_URL = "https://dev.api.myapp.com";
}
// Later usage
console.log("API endpoint: ", five.variable.API_URL);