Atatus supports monitoring Next.js application versions 16, and 17.

  1. Install the Atatus Node.js agent.

    copy
    icon/buttons/copy
    npm install --save atatus-nodejs
    
  2. You need to add NODE_OPTIONS='-r atatus-nodejs/start-next.js' to enable Atatus auto instrumentation for the Next.js backend. If you start your Next.js app using package.json, you can update your dev and start npm scripts as follows:

      // package.json
      {
        // ...
        "scripts": {
          "dev": "NODE_OPTIONS='-r atatus-nodejs/start-next.js' next dev",
          "build": "next build",
          "start": "NODE_OPTIONS='-r atatus-nodejs/start-next.js' next start",
          "lint": "next lint"
        },
        // ...
      }
    

    If you use a different process manager (e.g. PM2), set NODE_OPTIONS accordingly:

    NODE_OPTIONS='-r atatus-nodejs/start-next.js' next start
    
  3. Set the license key and app name using environment variables:

    export ATATUS_LICENSE_KEY="YOUR_LICENSE_KEY"
    export ATATUS_APP_NAME="YOUR_APP_NAME"
    export ATATUS_ANALYTICS=true
    export ATATUS_ANALYTICS_CAPTURE_OUTGOING=true
    export ATATUS_LOG_BODY="all"
    
  4. Restart your Next.js server.

    Restart the server and send a few requests. Your application metrics will appear in the Atatus dashboard within minutes.

Unhandled server errors are not captured

If unhandled server-side errors are not appearing in Atatus, configure the Next.js instrumentation hook. See Capturing Unhandled Server Errors.