You are using an unsupported browser. Please update your browser to the latest version on or before July 31, 2020.
Home > Project Editor > How do I store secrets, credentials or private data?
How do I store secrets, credentials or private data?

You can and should store secrets, credentials or private data securely inside the .env. This is a secure environment config section in your projects, useful for storing API keys and app credentials.


Only invited collaborators are able to see the contents of your .env. So, anonymous viewers or logged-in users who haven’t been invited to your project can’t see them.


When remixing an app the values are cleared so they’re not copied across.


For example, check out the .env file for our ~hello-express app:



To add secret data:

  1. Open the Project Editor and click .env in the left-side panel.
  2. Click the 'Add a Variable' button.
  3. Name your variable and then enter the secret information on the line next to the variable name.  The environment variables will update as you type.
  4. You can then reference your secret with process.env.[secret variable name].


This is how it will look for you and other project members:



This is how it will look for everyone else that clicks View Source:



and.... This is how it will look if someone remixes your project:



A note about data files:

  • In addition to using .env, you should create a folder called .data to safely store your data files. This folder isn’t copied across when a project is remixed.



Got more questions?  Check out our Community Forum

Open 24/7, the forum is where Glitch makers help each other and show off all the rad apps that they have created.  It's the friendliest community of coders on the Web!

82 out of 113 found this helpful

scroll to top icon