Tsallaka zuwa abun ciki
Justice Tech School

Environment Variables

process.env holds environment variables as strings. Use defaults and never commit secrets.

Example
process.env.APP = "demo";
const port = Number(process.env.PORT) || 3000;
console.log(process.env.APP, port, typeof process.env.HOME);

Result

demo 3000 string

Exercise

Default port.

const port = process.env.PORT ?? ;

Quiz Test

What type are env values?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.