This is a legacy documentation for Next.js application using Pages Router.
Using App Router? See current version of Next.js docs instead.
Install Logtail Next.js NPM package:
Set LOGTAIL_SOURCE_TOKEN and LOGTAIL_URL environment variables:
Set up Better Stack Next.js client in next.config.js:
Import Better Stack Next.js logger:
Use structured logging in client, edge, or server-side files:
You should see your logs in Better Stack โ Live tail.
Next.js version 12.1.4 or higher is required.
Please let us know at hello@betterstack.com.
We're happy to help! ๐
Get logger with automatic log flushing and built-in exception logging.
Wrap your Next.js route handlers with Better Stack:
Better Stack Next.js client provides four log levels: debug, info, warn, and error.
Stop sending debug logs to Better Stack:
Take advantage of automatic log flushing and built-in exception logging.
Wrap your server-side props with Better Stack:
We use cookies to authenticate users, improve the product user experience, and for personalized ads. Learn more.