Skip to main content

Installation

dldr is available on both npm and JSR, making it easy to install in any JavaScript or TypeScript project.

Package Managers

Install dldr from npm:
npm install dldr
The npm package is published as dldr

Importing

After installation, you can import dldr in your project:
import { load } from 'dldr';

// With caching
import { load } from 'dldr/cache';

Module Exports

dldr provides two main entry points:

dldr

Main ModuleThe core batching functionality without caching.
import { load, factory } from 'dldr';

dldr/cache

Cache ModuleBatching with built-in caching support.
import { load } from 'dldr/cache';

TypeScript Support

dldr is written in TypeScript and includes complete type definitions out of the box. No additional @types packages are needed.
import { load, type LoadFn } from 'dldr';

// Full type inference
const loader: LoadFn<User, string> = async (ids) => {
  // TypeScript knows ids is string[]
  // and expects Promise<(User | Error)[]>
  return fetchUsers(ids);
};

const user = await load(loader, '123');
// TypeScript knows user is type User

Runtime Requirements

dldr requires queueMicrotask support, which is available in all modern JavaScript environments including Node.js 11+, Deno, Bun, and all modern browsers.

Dependency

dldr has a single dependency:
  • object-identity - Used for creating identity keys from complex objects

Next Steps

Quick Start

Now that you’ve installed dldr, let’s build your first loader

Build docs developers (and LLMs) love