Skip to content

Framework integrations

These examples keep the API key on the server and return only the session handle and wallet URL to the caller. Set DLBR_ID_BASE_URL and DLBR_ID_API_KEY in the framework's server-side environment.

The request body below is intentionally small; production applications should validate it with their framework's preferred schema library before passing it to the SDK.

Express

sh
npm install express @dlbr/eid-sdk
ts
import express from "express";
import { DlbrId } from "@dlbr/eid-sdk";

const app = express();
app.use(express.json());

const id = new DlbrId({
  baseUrl: process.env.DLBR_ID_BASE_URL!,
  apiKey: process.env.DLBR_ID_API_KEY!,
  mode: "test",
});

app.post("/api/verification-sessions", async (_request, response, next) => {
  try {
    const session = await id.sessions.create({
      credentials: [{
        format: "mso_mdoc",
        issuer_id: "https://issuer.example",
        namespace: "org.iso.18013.5.1",
        claims: ["given_name"],
      }],
    });
    response.status(201).json({
      session_id: session.session_id,
      qr_code_url: session.qr_code_url,
    });
  } catch (error) {
    next(error);
  }
});

app.listen(process.env.PORT ?? 3000);

Fastify

sh
npm install fastify @dlbr/eid-sdk
ts
import Fastify from "fastify";
import { DlbrId } from "@dlbr/eid-sdk";

const app = Fastify();
const id = new DlbrId({
  baseUrl: process.env.DLBR_ID_BASE_URL!,
  apiKey: process.env.DLBR_ID_API_KEY!,
  mode: "test",
});

app.post("/api/verification-sessions", async (_request, reply) => {
  const session = await id.sessions.create({
    credentials: [{
      format: "mso_mdoc",
      issuer_id: "https://issuer.example",
      namespace: "org.iso.18013.5.1",
      claims: ["given_name"],
    }],
  });
  return reply.code(201).send({
    session_id: session.session_id,
    qr_code_url: session.qr_code_url,
  });
});

await app.listen({ port: Number(process.env.PORT ?? 3000), host: "0.0.0.0" });

Hono

sh
npm install hono @dlbr/eid-sdk
ts
import { Hono } from "hono";
import { DlbrId } from "@dlbr/eid-sdk";

type Env = { Bindings: { DLBR_ID_BASE_URL: string; DLBR_ID_API_KEY: string } };
const app = new Hono<Env>();

app.post("/api/verification-sessions", async (context) => {
  const id = new DlbrId({
    baseUrl: context.env.DLBR_ID_BASE_URL,
    apiKey: context.env.DLBR_ID_API_KEY,
    mode: "test",
  });
  const session = await id.sessions.create({
    credentials: [{
      format: "mso_mdoc",
      issuer_id: "https://issuer.example",
      namespace: "org.iso.18013.5.1",
      claims: ["given_name"],
    }],
  });
  return context.json({
    session_id: session.session_id,
    qr_code_url: session.qr_code_url,
  }, 201);
});

export default app;

Next.js App Router

Install the SDK in the Next.js application:

sh
npm install @dlbr/eid-sdk

Create app/api/verification-sessions/route.ts:

ts
import { NextResponse } from "next/server";
import { DlbrId } from "@dlbr/eid-sdk";

export const runtime = "nodejs";

export async function POST() {
  const id = new DlbrId({
    baseUrl: process.env.DLBR_ID_BASE_URL!,
    apiKey: process.env.DLBR_ID_API_KEY!,
    mode: "test",
  });
  const session = await id.sessions.create({
    credentials: [{
      format: "mso_mdoc",
      issuer_id: "https://issuer.example",
      namespace: "org.iso.18013.5.1",
      claims: ["given_name"],
    }],
  });
  return NextResponse.json({
    session_id: session.session_id,
    qr_code_url: session.qr_code_url,
  }, { status: 201 });
}

Production checklist

  • Keep DLBR_ID_API_KEY in server-side secrets, never NEXT_PUBLIC_* or browser bundles.
  • Use mode: "live" with an sk_live_ key and an HTTPS base URL in production.
  • Return a narrow response object; do not proxy the full SDK session object unless the client needs every URL.
  • Map DlbrIdApiError.statusCode and requestId into your framework's error and observability pipeline.

Built for developers integrating privacy-preserving identity verification.