Framework guides
Next.js
Install the SDK in the app that owns server routes:
npm install errorcoreKeep Errorcore in server-only modules. Do not expose ERRORCORE_API_KEY or ERRORCORE_DEK in client components or public env vars.
import { init } from "errorcore/nextjs";
init({
service: process.env.ERRORCORE_SERVICE_NAME,
deploymentEnv: process.env.ERRORCORE_ENVIRONMENT,
transport: {
type: "http",
url: process.env.ERRORCORE_INGEST_URL ?? "https://api-production-7ecf.up.railway.app/v1/ingest",
apiKey: process.env.ERRORCORE_API_KEY,
},
encryptionKey: process.env.ERRORCORE_DEK,
});Wrap production App Router handlers that can throw with withErrorcore() from errorcore/nextjs. The controlled first-event route can explicitly send one synthetic error:
import { captureError, flush } from "errorcore/nextjs";
export const runtime = "nodejs";
export const dynamic = "force-dynamic";
export async function GET() {
captureError(new Error("errorcore test error"));
await flush();
return Response.json({ sent: true }, { status: 202 });
}The Edge export is a no-op stub. Keep capture routes in the Node.js runtime.