TypeScript SDK

Installation

A complete, step-by-step guide to adding the Pdffillr SDK to your project — from verifying your runtime environment through to confirming that the package is installed correctly and ready to use.

npm registryNode.js ≥ 20 LTSESM + CommonJSTypeScript ≥ 4.9
What this page covers
Checking and meeting Node.js version requirements
Installing the SDK from the npm registry
Creating and securing your .env file with your API key
Loading environment variables with dotenv at startup
Verifying the package installed correctly in node_modules
Using the SDK with ESM (import) or CommonJS (require)

1. Prerequisites

Before installing the SDK, verify that your development environment meets the minimum runtime requirements. The Pdffillr SDK depends on features introduced in Node.js 20 LTS - most importantly, the native global fetch API - and will not function correctly on earlier Node.js releases.

Check your runtime versions
terminal
node --version
# Expected: v20.0.0 or higher
# e.g. v20.11.0

npm --version
# Expected: 9.0.0 or higher
# e.g. 10.2.4

Required versions

DependencyMinimum versionWhy it matters
Node.js20.0.0Native fetch, modern ESM resolution, and stable async iterator support. Non-EOL versions required.
npm9.0.0Ships with Node.js 20. Required for scoped package resolution.
TypeScript4.9 (optional)Needed only if you write TypeScript. Plain JavaScript requires no TS version.
Using nvm?

If you manage multiple Node.js versions with nvm, run nvm install 20 and nvm use 20 to switch to Node.js 20 LTS before installing.

Published on npm

The SDK is published as @pdffillr/sdk on the npm registry. No SSH key or GitHub access is required — standard npm install works out of the box.

On a version below Node.js 20?
Upgrade using the official installer at nodejs.org or via your version manager. Node.js 20 LTS is recommended for all new projects - it receives long-term support and security patches.

2. Install the Package

The Pdffillr SDK is published on the npm registry as @pdffillr/sdk. Install it with a single command. npm resolves the dependency, downloads the package, and installs it into node_modules exactly as any other registry package.

terminal
npm install @pdffillr/sdk

After installation completes, npm automatically adds the dependency entry to your package.json and generates a lock-file entry. Team members and CI pipelines running npm install on a fresh clone will install the exact same version, keeping your dependency pinned.

How the dependency appears in package.json
package.json
{
  "dependencies": {
    "@pdffillr/sdk": "^1.0.0"
  }
}

3. Set Up Your API Key

The SDK authenticates every request to the Pdffillr API using an API key. The recommended way to supply this key is through the PDFFILLR_API_KEY environment variable, which the SDK reads automatically at runtime. You configure this variable in a .env file that lives at the root of your project and is never committed to version control.

1
Add .env to your .gitignore

Before creating the file, make sure .env is listed in your .gitignore. Do this first - it ensures you cannot accidentally commit the file even in the same commit you create it.

.gitignore
# .gitignore
.env
.env.local
.env.production
node_modules/
2
Create the .env file and add your key

Create a .env file in the root of your project - the same directory as your package.json - and set the key variable. Replace the placeholder value with your real Pdffillr API key from the dashboard.

.env
# .env
# Replace the placeholder value with your actual Pdffillr API key.
# Never commit this file to version control.
PDFFILLR_API_KEY=your_api_key_here
Treat your API key like a password
An exposed API key gives anyone full access to your Pdffillr account. If a key is leaked - through a public repository, a log file, or a crash dump - rotate it immediately from the Pdffillr dashboard. Rotation invalidates the old key instantly. Use separate keys for development, staging, and production so that a leak in one environment does not affect the others.

4. Load Environment Variables

Node.js does not automatically read .env files. You need a loader - the standard choice is dotenv - to parse the file and populate process.env before any module that reads those variables is imported. Installing and calling the loader at the very top of your application entry point is the recommended pattern.

Step 1 - Install the dotenv package
terminal
npm install dotenv
ESM / TypeScript (recommended)
src/index.ts
// Entry point of your application - e.g. src/index.ts
// Import dotenv/config before any other module that reads process.env.
import 'dotenv/config';

import Pdffillr from '@pdffillr/sdk';

const client = new Pdffillr({
  apiKey: process.env['PDFFILLR_API_KEY'], // This is the default and can be omitted
});
CommonJS
src/index.js
// CommonJS entry point - e.g. src/index.js
require('dotenv').config();

const Pdffillr = require('@pdffillr/sdk');

const client = new Pdffillr({
  apiKey: process.env['PDFFILLR_API_KEY'], // This is the default and can be omitted
});

How the loader works

01
dotenv reads your .env fileThe loader opens .env from the current working directory, parses each KEY=VALUE line, and writes the values to process.env.
02
process.env is populatedOnce dotenv runs, process.env['PDFFILLR_API_KEY'] holds your key value. The SDK constructor reads it automatically from there.
03
Existing variables are never overwrittenIf a variable is already set in the shell environment (e.g. in a production deployment), dotenv skips it - real environment variables always take precedence over .env values.
In production, skip dotenv entirely
Managed deployment platforms - AWS, Vercel, Render, Railway, Fly.io - provide a native environment variable interface. Set PDFFILLR_API_KEY in your platform's environment settings instead of shipping a .env file. The SDK will read it from process.env without dotenv being present at all.

5. Verify the Install

Once the package is installed and your environment variable is configured, run two quick checks to confirm everything is in place before you write any application code. Catching a misconfiguration at this stage is far faster than debugging it mid-feature.

1
Confirm the package is present in node_modules
terminal
ls node_modules | grep pdffillr
# Expected output:
# @pdffillr
2
Run a quick smoke test

Create a temporary file, import the SDK, instantiate the client, and log the result. If the client initialises without throwing, your install is correct. Delete this file before committing.

smoke-test.ts
// smoke-test.ts  -  run with: npx ts-node smoke-test.ts
import 'dotenv/config';
import Pdffillr from '@pdffillr/sdk';

const client = new Pdffillr({
  apiKey: process.env['PDFFILLR_API_KEY'], // This is the default and can be omitted
});

// If this line executes without throwing, your install is working.
console.log('SDK client ready:', typeof client);
If the import fails
A module-not-found error at this step means the package did not install successfully. Delete node_modules and your lock file, then re-run npm install. If the error persists, verify that @pdffillr/sdk is listed in your package.json dependencies.

6. Module System Support

The Pdffillr SDK ships both an ESM build and a CommonJS build. npm automatically selects the correct build based on your project's module system. You do not need to configure anything - just import the package using the syntax that matches your codebase.

ESM / TypeScript

Use import syntax. This is the recommended approach for TypeScript projects and Node.js projects with "type": "module" in package.json.

esm-usage.ts
// TypeScript / modern ESM  (package.json "type": "module")
import Pdffillr from '@pdffillr/sdk';

const client = new Pdffillr({
  apiKey: process.env['PDFFILLR_API_KEY'], // This is the default and can be omitted
});
CommonJS

Use require() syntax. This is the default module system for Node.js when "type": "module" is absent from package.json.

cjs-usage.js
// CommonJS  (default Node.js module system)
const Pdffillr = require('@pdffillr/sdk');

const client = new Pdffillr({
  apiKey: process.env['PDFFILLR_API_KEY'], // This is the default and can be omitted
});
Module systemSyntaxWhen to use
ESMimport … from …TypeScript projects, or package.json "type": "module"
CommonJSrequire(…)Legacy Node.js projects without ESM configured
Mixing ESM and CommonJS
If you use ESM in a project that also has CommonJS dependencies, Node.js handles the interop automatically for most cases. If you encounter an ERR_REQUIRE_ESM error, set "type": "module" in your package.json and convert your entry point to use import syntax.

Next steps

Was this page helpful?
PDFFILLR.AI logo

PDFFILLR.AI

The intelligent layer for modern fund
administration. Automating high-stakes
documentation with precision and speed.

Powered byEngineersMind