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.
Installation
bun add @learncard/didkit-plugin-nodeThis package includes prebuilt binaries for common platforms (Linux x64, macOS x64/ARM64, Windows x64). If your platform isn't supported, you'll need Rust installed to compile from source during installation.
Usage
Basic Setup
Configuration Options
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:
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:
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
Supported Platforms
Prebuilt binaries are included for:
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
Related Documentation
DIDKit (WASM) - The browser-compatible WASM version
Plugin System - How plugins work
Verifiable Credentials - VC concepts
DIDs - DID concepts
Last updated
Was this helpful?