Next.js
Set up OneMinute Logs in Next.js.
Install the SDK, create your API key, initialize the logger, and start sending structured production events from routes, server actions, or backend utilities.
If you are using Cursor, Claude Code, Codex, Antigravity, or any other AI IDE, follow our Setup with AI guide.
1. Install the SDK
Add the OneMinute Logs SDK for this framework.
npm install @oneminutelogs/next2. Create an API key
Create an API key from your OneMinute Logs dashboard and add it to your environment variables. Open the API key guide.
ONE_MINUTE_LOGS_API_KEY=your_oml_api_key3. Create lib/logs.ts
Initialize the logger once and import it anywhere you need to send events.
import { createLogger } from "@oneminutelogs/next";
export const log = createLogger({
apiKey: process.env.ONE_MINUTE_LOGS_API_KEY!,
appName: "my-next-app",
environment: process.env.NODE_ENV || "development",
});In Next.js, keep this file in a shared server-side location like lib/logs.ts and import it from route handlers or server-only modules.
4. Send events
Use event types like info, warning, error, audit, and metric to keep your production timeline useful and searchable.
import { log } from "@/lib/logs";
export async function POST() {
await log.info({
message: "Checkout started",
service: "web",
});
await log.warning({
message: "Payment attempt is taking longer than expected",
service: "billing",
importance: "medium",
});
await log.error({
message: "Payment failed",
service: "billing",
operation: "charge-card",
importance: "critical",
});
await log.audit({
message: "Admin updated a customer plan",
service: "admin",
security: {
actorId: "user_123",
action: "plan.updated",
},
});
await log.metric({
message: "API latency recorded",
service: "api",
metrics: {
durationMs: 248,
route: "/api/checkout",
},
});
return Response.json({ ok: true });
}What's next?
Alerts
Create alert rules from your production events.
Webhooks
Send verified notifications to your own endpoint.
Live Events
Stream incoming events into your own dashboard.
Search & Filters
Query stored events with filters and search terms.
After events are flowing, alerts, webhooks, live dashboards, and search all work from the same event pipeline.