How to Use Environment Variables in Codesphere

In this tutorial, I’m going to show you how you can set up environment variables in your Codesphere app in just a couple of minutes.

August 8, 2021 1 Min Read
How to Use Environment Variables in Codesphere
How to Use Environment Variables in Codesphere

Codesphere

From everyone in the Codesphere Team:)

Table of Contents

In this tutorial, I’m going to show you how you can set up environment variables in your Codesphere app in just a couple of minutes.

If you have certain variables, such as database URLs or API keys, that you don’t want publicly viewable in a repository, you can use environment variables to only make these variables accessible in your deployment environment.

In this example, we have a simple React Typescript Application. We can go to the infrastructure tab and click environment variables.

From there, let’s add a variable. Now if you are using React, all of your environment variables have to start with REACT_APP_, but specific naming conventions are going to differ from language to language.

Let’s have this variable store an API Key, and let’s just give it a random string as a value.

Now to prove that it’s accessible, let’s go to our app.tsx file and display a header that shows this value. In React, we can access the value with process.env.REACT_APP_API_KEY

<h2>{process.env.REACT_APP_API_KEY}</h2>

Again, the specific syntax for how to access your Environment variables is dependent on the language and framework you are using, but this process remains constant in terms of creating your variables in Codesphere.


Thanks for reading, to learn more about how Codesphere is rebuilding the cloud experience, check out Codesphere.com

About the Author

How to Use Environment Variables in Codesphere

Codesphere

From everyone in the Codesphere Team:)

We are building the next generation of Cloud, combining Infrastructure and IDE in one place, enabling a seamless DevEx and eliminating the need for DevOps specialists.

More Posts

Changelog LTS Version Q3 25

Changelog LTS Version Q3 25

New cli, restricted domains, improved git integration, frontend improvements and more in the latest LTS version.

From Dev Chaos to Cloud Clarity: No More “It Works on My Machine”

From Dev Chaos to Cloud Clarity: No More “It Works on My Machine”

Tired of the “It works on my machine” nightmare? This blog explores how Codesphere eliminates environment drift by letting you develop in production-grade cloud workspaces. so your code runs the same everywhere, from dev to deploy. Build smarter, ship with confidence.

From Friction to Flow — How Codesphere Transforms Productivity

From Friction to Flow — How Codesphere Transforms Productivity

Discover how Codesphere transforms software development by unifying coding, CI/CD, deployment, and infrastructure into one seamless platform. Boost developer productivity, reduce DevOps overhead, and go from idea to live without switching tools or breaking flow.