Next.js logging with alerts, in 5 minutes
Logs and errors from your routes and server actions, errors that blow up in your customers' browsers, and an alert when an order never finishes. On Vercel or your own server.
- 1
Install
npm i @estiaje/sdk - 2
Your key
Create your account and put the key in
ESTIAJE_TOKEN. Or ask your AI “connect this repo to Estiaje” (the connector). Without the key nothing leaves over the network: you can instrument today. - 3
Your logs and errors, at startup (instrumentation.ts)
● Not tested yet// lib/estiaje.ts import { estiajeFromEnv } from '@estiaje/sdk'; export const estiaje = estiajeFromEnv({ service: 'tienda-web' }); // instrumentation.ts export async function register() { if (process.env.NEXT_RUNTIME === 'nodejs') { const { estiaje } = await import('./lib/estiaje'); estiaje.capturarConsola(); estiaje.capturarErrores(); } }// server.ts (Next.js with a custom server) import { estiaje } from './lib/estiaje'; estiaje.capturarConsola(); estiaje.capturarErrores(); createServer((req, res) => estiaje.middleware()(req, res, () => handle(req, res)) // each request's thread ).listen(3000);<!-- app/layout.tsx, before </head>; create the cp_live_ key in Errors --> <script src="https://estiaje.mx/navegador.js" data-llave="cp_live_…" data-servicio="tienda-web" async></script> - 4
The process that must finish
// app/api/orders/route.ts import { estiaje } from '@/lib/estiaje'; export async function POST(req: Request) { // … you charge the order … estiaje.event('order.paid', { order_id, amount }); await estiaje.flush(); // on Vercel, before responding: the function freezes return Response.json({ ok: true }); } - 5
The alert
In the dashboard, under Processes: “every
order.paidexpects itsorder.shipped, byorder_id, within 30 minutes”. If it never comes, you get a phone, email or Slack alert, with the money at risk.
And if you want more
- On Vercel, always
await estiaje.flush()before responding: a function that already responded freezes and whatever hadn't gone out stays behind. - Your site's errors arrive with the visitor's steps before the error, tied to the order with
estiaje.pedido('A-1042'). - Your deploys:
npx @estiaje/sdk desplegadoin your CI or Vercel's build step.
Everything else is in the full docs.
The long guide: Node.js logging in production: pino or winston
Create account, 14 days of Pro
No card required.