Next.js with AllStak
Monitor your Next.js app — client, server, and route handlers — with the AllStak Next.js SDK.
- Source repository:
- AllStak/allstak-next
- Source README:
- README.md
- SDK version:
- 0.3.0
- Installation source:
- npm
- Last verified:
- 2026-05-31
Installation
Install the SDK from npm.
npm install @allstak/nextConfiguration
Register AllStak on the server in instrumentation.ts, and load the client bootstrap from instrumentation-client.ts (App Router).
// instrumentation.ts
export async function register() {
const { registerAllStak } = await import('@allstak/next');
registerAllStak({
apiKey: process.env.ALLSTAK_API_KEY,
environment: process.env.NODE_ENV ?? 'production',
release: process.env.NEXT_PUBLIC_RELEASE,
});
}
// instrumentation-client.ts (project root)
export * from '@allstak/next/client';Basic example
Wrap a route handler to report failures with telemetry.
import { withAllStakRouteHandler } from '@allstak/next';
export const GET = withAllStakRouteHandler(async () => {
return Response.json({ ok: true });
});Capturing errors
Capture exceptions explicitly, or wrap a component with the error boundary.
import { captureException } from '@allstak/next';
await captureException(new Error('checkout failed'), { route: '/checkout' });
// or, in a client component:
import { withAllStakErrorBoundary } from '@allstak/next';
export default withAllStakErrorBoundary(PageContent, { fallback: <p>Something went wrong.</p> });Tracking requests
Outbound fetch is instrumented automatically (enableOutboundHttp, default true), capturing the call and injecting W3C traceparent + baggage headers. Use withAllStakRouteHandler / withAllStakServerAction for server entry points.
Best practices
- Use the instrumentation hook so the server is monitored from cold start.
- Provide the release via NEXT_PUBLIC_RELEASE for per-deploy grouping.
- Configure the browser via NEXT_PUBLIC_ALLSTAK_* environment variables.