Pages
Contents
@xpulse/dotenv β Component Spec
Status: CONCEPT Β· Created March 2026 Parent:
GLOBAL_concept-ecosystem.md
Overview
Loads .env files and populates process.env. Zero dependencies.
Not a wrapper around dotenv (npm) β a lean, custom implementation.
Only what xPulse needs, no overhead.
API
Loading
| import dotenv from '@xpulse/dotenv'; |
| // Loads .env from the current working directory |
| await dotenv.load(); |
| // Explicit path |
| await dotenv.load({ path: '/app/.env' }); |
Access
After dotenv.load() all values are available in process.env:
| process.env.PORT // '3000' |
| process.env.CHAT_URL // 'https://chat.xpulse.one' |
Additionally directly via dotenv:
| dotenv.get('PORT') // '3000' |
| dotenv.get('PORT', '8080') // '3000' (fallback if not set) |
| dotenv.get('MISSING', '42') // '42' |
Introspection
| // Has it already been loaded? |
| dotenv.loaded; |
| // β true |
.env Format
Standard .env syntax:
| # Comments are ignored |
| PORT=3000 |
| CHAT_URL=https://chat.xpulse.one |
| # Quotes are stripped |
| APP_NAME="xPulse Web" |
| APP_NAME='xPulse Web' |
| # Empty lines are ignored |
| # Values with spaces require quotes |
| GREETING="Hello World" |
Behaviour
- Existing
process.envvalues are not overwritten β system environment takes precedence - Comments (
#) and empty lines are ignored - Quotes (
"and') are stripped from values - No interpolation (
${VAR}in.envis not resolved β that is handled by@xpulse/config)
Package Structure
| /dotenv/ |
| index.js β default export: dotenv object |
| README.md |
| package.json |
Dependencies
None.
Debug Integration
When @xpulse/debug is installed as a devDependency, @xpulse/dotenv
automatically provides a DataCollector. @xpulse/debug discovers it via
node_modules/@xpulse/dotenv/src/datacollectors/ β no configuration needed.
| "optionalDependencies": { |
| "@xpulse/debug": "^1.0.0" |
| } |
The EnvCollector (name: 'env', icon: 'π') shows in the Web Profiler:
- Loaded Files (list): all loaded
.envfiles with their full path - Process ENV (table): snapshot of all
process.enventries at the time of the request with key and value
No toolbar badge.
Open Questions
| Question | Status |
|---|---|
Multiline values in .env? |
TBD β not for now |
Automatically load .env.production / .env.development? |
TBD |