Next.js integration
The Fidemark SDK runs in Node.js: use it from a Next.js Route Handler or Server Action, never from a "use client" component (the EAS contract calls require server-side RPC access for the read-only path, and you don’t want signing keys in browser bundles).
App Router pattern
Section titled “App Router pattern”app/api/attest-ai/route.ts:
import { NextRequest, NextResponse } from "next/server";import { Fidemark } from "@fidemark/sdk";
const fidemark = new Fidemark({ network: "base-sepolia", privateKey: process.env.FIDEMARK_PRIVATE_KEY!,});
export async function POST(req: NextRequest) { const { content, modelId, prompt, parameters } = await req.json();
const result = await fidemark.attestAI({ content, modelId, provider: "anthropic", prompt, parameters, });
return NextResponse.json(result);}Verification page (server component)
Section titled “Verification page (server component)”app/[uid]/page.tsx:
import { Fidemark } from "@fidemark/sdk";import { JsonRpcProvider } from "ethers";
const fidemark = new Fidemark({ network: "base-sepolia", provider: new JsonRpcProvider("https://sepolia.base.org"),});
export default async function Verify({ params }: { params: Promise<{ uid: string }> }) { const { uid } = await params; const att = await fidemark.verify(uid); return <pre>{JSON.stringify(att, null, 2)}</pre>;}This is the same pattern verify.fidemark.dev uses: a server component renders the attestation as static-feeling HTML; the verifier doesn’t need a wallet or any JavaScript.
Caveats
Section titled “Caveats”- Add
transpilePackages: ["@fidemark/sdk"]tonext.config.ts. - Don’t import the SDK into client components: keep RPC and key handling server-side.
- For high-traffic verify pages, cache
verify()results: an attestation is immutable except for revocation, so a short cache (~30 seconds) is safe.