---
title: "Get the value of an environment variable"
description: "Retrieve environment variable values in various environments like CRA, Node, VITE, and Deno."
date: "2025-10-02"
tags: ["typescript","environment","variables","frontend"]
canonical: "/snippets/typescript/function/get-env"
---

import { Code } from '@astrojs/starlight/components'
import Source from './get-env.ts?raw'

## Get the value of an environment variable

This works for the following environments: `CRA`, `node`, `VITE`, `deno`.

<Code code={Source} lang="ts" title="get-env.ts" wrap />
