Node.js
How to set up Keyshade in a Node.js app.
Keyshade securely manages your environment variables and secrets — no more .env files, and nothing sensitive committed to your repo.
This guide will walk you through setting up Keyshade in a Node.js app, step by step.
Prefer to dive straight into code? Jump to Running Your App
Coming Up
Here's what this guide covers:
Create a Node.js app
Set up a profile using your API key
Create a project and environment in the Keyshade dashboard
Add secrets and runtime variables
Link your local project with
keyshade initRun your app with
keyshade runUse
process.envto access values in your Node.js code
💡 New to Keyshade? Start with What is Keyshade? to get a quick overview of how it works.
Create a Node.js Project
If you don't already have a Node.js app, create one:
For TypeScript projects, add the necessary dependencies:
Need more help with Node.js project setup? Check out the official Node.js documentation.
Install the Keyshade CLI
The Keyshade CLI lets you fetch secrets, inject env variables, and manage profiles all from your terminal.
Install it globally:
Note: Node.js v24 may cause issues with the Keyshade CLI, so use v20 (LTS) for best compatibility.
See Installing the CLI for more info.
Set Up Your Profile
To connect your local environment with Keyshade, create or use a profile.
If this is your first time using Keyshade, follow this guide to set up your profile.
If you've already used Keyshade before:
You can verify which profile is active with:
Create a Project and Add Secrets
To get started:
Go to the Keyshade Dashboard
Click "Create Project"
Name your project (e.g.
nodejs-app)Inside the project, click the "Secrets" tab
Add your secrets (e.g.
API_KEY,DATABASE_URL)Add your variables (e.g.
PORT)
💡 Secrets vs Variables:
Secrets are sensitive values — like API keys or access tokens — and are encrypted for security.
Variables are non-sensitive settings — like ports, feature flags, or toggles — and are stored as plain values, not encrypted.
Need help with projects and secrets? See Managing Secrets & Variables
Initialize Keyshade in Your Project
In order to use the configurations you just created on the dashboard, you would need to initialize Keyshade in your project. This generates the necessary configurations for the CLI to tap into your Keyshade project.
From your project root:
Run the init command to link your local project with the Keyshade dashboard:
You'll be guided through selecting your workspace, project, and environment.
Want to skip the prompts?
This will generate a keyshade.json file in your project root.
More on this in the CLI Reference
Run Your App with Secure Env Injection
Start your Node.js app with Keyshade:
For JavaScript:
For TypeScript:
Or if you have npm scripts defined in package.json:
Example output:

Keyshade will inject your secrets and variables securely at runtime.
Access Secrets and Variables in Your Code
Once your app is running with keyshade run, use process.env to access any injected values — no extra setup needed.
For example, if you added a secret named DATABASE_URL and a variable named PORT in the Keyshade dashboard:
In JavaScript:
In TypeScript:
Example Node.js Server
Create a simple Express server in index.js:

Now run it with keyshade run -- node index.js and you'll see your server start with all secrets securely injected.
Visit http://localhost:3000 to confirm your secrets are being injected properly. See below for reference:

You're All Set 🚀
Your Node.js app is now securely powered by Keyshade — no .env files, no leaking secrets, and no environment mismatches.
Last updated