Guides
Node SDK
Load Bulgur values at startup or read them per request without changing process.env.
Token mode
Install bulgur 1.4.0 or newer on Node.js 18 or newer. Create a runtime-scoped token bound to the project or environment, then build a DSN for the target. The SDK uses HTTPS for Bulgur Cloud.
Pass dsn explicitly, set process BULGUR_DSN, or place only BULGUR_DSN in a current-directory .env. This is the precedence order. The SDK does not import other file entries or interpolate them.
npm install bulgur@^1.3.0BULGUR_DSN=bulgur://blg_replace_with_runtime_token@api.bulgur.dev/your-org/your-project/productionconst { load } = require("bulgur");
async function main() {
await load(); // one-time startup: writes values to process.env
}
main().catch(console.error);Keep the DSN on the server and out of source control. Do not expose its token through NEXT_PUBLIC_ variables, client components, or browser bundles.
Request-local reads
loadValues returns a plain object for that call and does not modify process.env. Use it when concurrent requests should keep their values separate. load writes values to process.env; existing variables win unless override: true is passed.
const { loadValues } = require("bulgur");
async function handleRequest() {
const values = await loadValues();
return connectToDatabase(values.DATABASE_URL);
}Local file options
By default token mode checks .env in the current working directory only when no explicit or process DSN was supplied. Use envFile to choose another path or false to disable file lookup. A missing implicit .env is fine; a missing explicitly selected file or malformed file fails, even with optional: true.
Workload OIDC modes are explicit. They do not read the local .env or fall back to a token when authentication fails. Use loadValues inside a request handler when values must stay request-local.
await loadValues({ envFile: "./config/local.env" });
await loadValues({ envFile: false, dsn: process.env.BULGUR_DSN });