Capture production errors automatically in your Express and Next.js applications.
npm install @bugstack/sdk
const express = require('express');
const { initBugStack } = require('@bugstack/sdk');
const app = express();
// Initialize bugstack
initBugStack({ apiKey: process.env.BUGSTACK_API_KEY });
app.get('/', (req, res) => {
res.send('Hello World');
});
// bugstack automatically captures unhandled errors
app.listen(3000);
// app/layout.tsx
import { initBugStack } from '@bugstack/sdk';
// Initialize bugstack once at the app root
initBugStack({ apiKey: process.env.BUGSTACK_API_KEY! });
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
<html lang="en">
<body>{children}</body>
</html>
);
}
View the full source code, report issues, and contribute on GitHub.