@extn/segi-nextjs
v0.2.8
Published
Next.js integration for the segi error monitoring service
Readme
@extn/segi-nextjs
Install
pnpm add @extn/segi-nextjsClient setup
In app/segi-init.tsx (a client component):
"use client";
import { initSegiBrowser } from "@extn/segi-nextjs/client";
initSegiBrowser({
publicKey: process.env.NEXT_PUBLIC_SEGI_KEY!,
environment: process.env.NEXT_PUBLIC_VERCEL_ENV ?? "development",
release: process.env.NEXT_PUBLIC_VERCEL_GIT_COMMIT_SHA,
});
export default function SegiInit() {
return null;
}Mount once in your root layout.tsx:
import SegiInit from "./segi-init";
export default function RootLayout({ children }) {
return (
<html><body><SegiInit />{children}</body></html>
);
}Server setup
In instrumentation.ts:
export async function register() {
if (process.env.NEXT_RUNTIME === "nodejs") {
const { initSegiNext } = await import("@extn/segi-nextjs");
initSegiNext({
publicKey: process.env.SEGI_KEY!,
environment: process.env.NODE_ENV,
});
}
}Anywhere on the server, the same package re-exports captureException and
captureMessage for explicit reporting:
import { captureException } from "@extn/segi-nextjs";
try {
// …
} catch (err) {
captureException(err);
throw err;
}Session recording (planned)
Drop a <SegiReplayProvider> into your root layout to add full DOM replay + heatmaps to the same project. It wires rrweb to the App Router's usePathname() so route changes flush correctly, and lazily imports rrweb so non-replay pages pay zero bundle cost.
// app/layout.tsx
import { SegiReplayProvider } from "@extn/segi-nextjs/replay";
export default function RootLayout({ children }) {
return (
<html><body>
<SegiReplayProvider publicKey={process.env.NEXT_PUBLIC_SEGI_KEY!} />
{children}
</body></html>
);
}endpoint defaults to the hosted segi service — only set it when self-hosting. The provider respects the project-level recording toggle in your segi dashboard — turning it off there pauses recording without redeploys. Quotas: Free 10 / Team 30 / Enterprise ∞ per project per month; full design in docs/12-session-recording.md.
Docs
Licence
Copyright (c) 2026 Extension Co., Ltd. All rights reserved. Use of this package is governed by the LICENSE file in this package and the segi service Terms of Service at https://segi.extn.ai/tnc — it is not open source.
