This page explains how to send data from your Next.js app to Axiom using the next-axiom library.
Event type | Axiom Vercel app | next-axiom library |
---|---|---|
Application logs | Yes | Yes |
Web Vitals | No | Yes |
HTTP logs | Yes | Soon |
Build logs | Yes | No |
npm install --save next-axiom
to install the latest version of next-axiom.NEXT_PUBLIC_AXIOM_DATASET
is the name of the Axiom dataset where you want to send data.NEXT_PUBLIC_AXIOM_TOKEN
is the Axiom API token you have generated.next.config.ts
file, wrap your Next.js configuration in withAxiom
:middleware.ts
file in the root folder of your Next.js app:
AxiomWebVitals
component from next-axiom to the app/layout.tsx
file:
fields
object.
withAxiom
to add a logger to your request and log exceptions automatically:
useLogger
from next-axiom to your component:
Logger
from next-axiom to your component, and call flush before returning:
debug
is the default setting. It means that you send all logs to Axiom.info
warn
error
means that you only send the highest-level logs to Axiom.off
means that you don’t send any logs to Axiom.app
folder.error.tsx
file.useLogger
from next-axiom to send the error to Axiom. For example:log.with
to create an intermediate logger. For example: