For the complete documentation index, see llms.txt. This page is also available as Markdown.

DIDKit (Node)

High-performance native Node.js DIDKit plugin using N-API

Overview

@learncard/didkit-plugin-node is a high-performance native Node.js plugin that provides the same DID and Verifiable Credential functionality as the standard WASM-based DIDKit plugin, but compiled directly to native code using Rust and N-API.

This plugin is ideal for server-side applications where performance is critical, such as credential issuance services, verification endpoints, and batch processing workflows.

When to use this plugin:

  • βœ… Node.js server applications (Express, Fastify, NestJS, etc.)

  • βœ… Serverless functions (AWS Lambda, Vercel, etc.)

  • βœ… CLI tools and scripts

  • βœ… High-throughput credential processing

When to use the WASM plugin instead:

  • Browser applications

  • React Native / mobile apps

  • Environments without native compilation support

Installation

bun add @learncard/didkit-plugin-node

Usage

Basic Setup

Configuration Options

Parameter
Type
Default
Description

input

InitInput

undefined

Optional initialization input (for API compatibility with WASM version)

allowRemoteContexts

boolean

false

Whether to allow fetching unknown JSON-LD contexts over HTTP

Features

Embedded JSON-LD Contexts

Like the WASM version, the native plugin uses SSI's 50+ embedded JSON-LD contexts. Both versions avoid HTTP requests for common contexts:

  • W3C Credentials v1/v2

  • W3C Security contexts

  • DID Core contexts

  • Open Badges v2/v3

  • CLR v2

  • LearnCard Boosts contexts

  • And many more...

Unknown contexts can optionally be fetched via HTTP if allowRemoteContexts is enabled.

Async Operations

All operations that may involve network requests (DID resolution, credential issuance/verification) are truly async and won't block Node.js's event loop:

DID Web Caching

The plugin includes built-in caching for did:web resolution to avoid redundant HTTP requests:

API Reference

The native plugin exposes the same API as the WASM DIDKit plugin:

Key Generation

DID Operations

Credential Operations

Presentation Operations

JWE Encryption

Performance Comparison

Cold Start (The Main Benefit!)

The biggest advantage of native over WASM is cold start time - critical for serverless functions, CLI tools, and worker threads:

Mode
Cold Start
Speedup

WASM

~1109ms

baseline

Native

~62ms

17.9x faster

WASM requires fetching and compiling the binary on every fresh Node process, while native loads instantly. You save ~1047ms per cold start.

Warm Operations

Once initialized, native is still faster for most operations:

Operation
WASM (ms)
Native (ms)
Speedup

issueCredential()

2.97

1.77

1.67x faster

verifyCredential()

1.97

1.68

1.18x faster

createJwe()

0.34

0.10

3.29x faster

decryptJwe()

0.10

0.05

2.15x faster

createDagJwe()

0.23

0.11

2.16x faster

decryptDagJwe()

0.08

0.05

1.53x faster

When to use native: Server environments where cold start matters (serverless, CLI tools, worker threads).

Run benchmarks yourself: cd tests/benchmarking && bun run benchmark

Supported Platforms

Prebuilt binaries are included for:

Platform
Architecture
Status

Linux

x64 (glibc)

βœ… Included

Linux

x64 (musl)

βœ… Included

Linux

ARM64

βœ… Included

macOS

x64 (Intel)

βœ… Included

macOS

ARM64 (Apple Silicon)

βœ… Included

Windows

x64

βœ… Included

For other platforms, the package will attempt to compile from source during installation (requires Rust toolchain).

Troubleshooting

Binary Not Found

If you see an error like "No .node binary found":

Compilation Errors

If compilation fails, ensure you have the Rust toolchain installed:

Memory Issues in Serverless

For serverless environments with limited memory, the native plugin is more memory-efficient than WASM. However, if you encounter issues:

Migration from WASM Plugin

The native plugin is a drop-in replacement for the WASM plugin. Simply change the import:

All method signatures and return types are identical.

Architecture

Last updated

Was this helpful?