npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

nestjs-infisical

v2.2.3

Published

CLI-free Infisical secrets loader for NestJS that fetches secrets via the HTTP API before application bootstrap and injects them into process.env.

Readme

nestjs-infisical

CLI-free Infisical secrets loader for NestJS.

Loads secrets from Infisical via the HTTP API before application bootstrap, injects them into process.env, and works seamlessly with @nestjs/config.

npm node license


Why nestjs-infisical exists

Secrets loading is global, side-effectful, and order-sensitive.

Running Infisical logic inside NestJS modules, providers, or lifecycle hooks leads to:

  • Non-deterministic startup order
  • Race conditions between modules
  • Hard-to-debug configuration issues

nestjs-infisical follows the same approach used by mature infrastructure tooling: load secrets before the framework starts.

This guarantees predictable startup behavior across:

  • Local development
  • Docker
  • CI/CD
  • Production environments

Architecture (pre-bootstrap loader)

Startup flow:

  1. Optional dotenv load
  2. Resolve configuration (options → environment variables)
  3. Authenticate with Infisical
  4. Fetch secrets via Infisical HTTP API
  5. Inject secrets into process.env
  6. Bootstrap NestJS
  7. @nestjs/config reads from process.env

Diagram:

dotenv → Infisical Auth → Infisical HTTP API → process.env → NestJS → ConfigModule


Authentication modes

This package supports two Infisical authentication methods.

Recommended: Universal Authentication

Uses a short-lived access token generated from a client ID and client secret.

Best suited for:

  • Production
  • CI/CD pipelines
  • Docker / Kubernetes
  • Machine-to-machine access

Environment variables:

INFISICAL_CLIENT_ID
INFISICAL_CLIENT_SECRET


Service / Personal Token (supported)

Uses a long-lived Infisical token.

Best suited for:

  • Local development
  • Prototyping
  • Backward compatibility

Environment variable:

INFISICAL_TOKEN


Authentication priority

If both authentication methods are provided:

  • Service token is used
  • A warning is logged

Installation

npm install nestjs-infisical

Requirements:

  • Node.js 18 or newer

Usage (recommended)

main.ts

import { loadInfisical } from 'nestjs-infisical';
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';

async function bootstrap() {
  await loadInfisical({
    debug: true
  });

  const app = await NestFactory.create(AppModule);
  await app.listen(3000);
}

bootstrap();

That is all you need.


Configuration resolution order

Configuration is resolved in this order:

  1. dotenv (unless disabled)
  2. Explicit options passed to loadInfisical
  3. Environment variables (process.env)

Required configuration:

INFISICAL_PROJECT_ID
INFISICAL_ENVIRONMENT

Authentication (choose one):

INFISICAL_TOKEN
or
INFISICAL_CLIENT_ID + INFISICAL_CLIENT_SECRET

Optional:

INFISICAL_BASE_URL (defaults to Infisical Cloud)


Zero-config usage

If everything is defined in .env:

INFISICAL_CLIENT_ID=xxx
INFISICAL_CLIENT_SECRET=yyy
INFISICAL_PROJECT_ID=zzz
INFISICAL_ENVIRONMENT=dev
await loadInfisical();

Mixed configuration example

await loadInfisical({
  environment: 'production',
  debug: true
});

Missing values are automatically resolved from process.env.


Disable dotenv (Docker / Kubernetes)

await loadInfisical({
  dotenv: false
});

Failure behavior

  • failFast: true (default)
    Application startup fails if Infisical cannot be reached

  • failFast: false
    Logs a warning and continues without secrets


Compatibility with @nestjs/config

Because secrets are loaded before NestJS starts, @nestjs/config works automatically with no special integration.

ConfigModule.forRoot({
  isGlobal: true
});

What this package does NOT do

  • No Infisical CLI usage
  • No token rotation or refresh
  • No background polling
  • No caching
  • No retries
  • No NestJS lifecycle hooks
  • No decorators
  • No health checks

Versioning note

v2.x introduces a pre-bootstrap loader architecture. If you were using a module-based approach, migrate by moving Infisical loading into main.ts.


Repository

GitHub:
https://github.com/kgoel085/nest-js-infisical-module


License

MIT