fix: Update nextjs-app-router example for Next.js ^16 and TypeScript compatibility#374
Merged
Merged
Conversation
Member
|
can you update this to use the hybrid agent? you'll have to disable |
nextjs-app-router example for Next.js >=15 and TypeScript compatibilitynextjs-app-router example for Next.js ^16 and TypeScript compatibility
bizob2828
requested changes
Jun 3, 2026
bizob2828
left a comment
Member
There was a problem hiding this comment.
one small issue in the README, otherwise this works
bizob2828
approved these changes
Jun 3, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bug fix
Resolves the TypeScript type error when using the Turbopack configuration example in a
next.config.tsfile.The original example showed:
This mirrors webpack's callable interface, but
TurbopackOptionsis a plain object — not a function — so TypeScript rejects it with:Changes:
next.config.js→next.config.tswith proper types (import type { NextConfig }, typed const,export default)nrExternalsis webpack-specific and does not apply to Turbopack — newrelic is already automatically excluded from bundling in Next.js 15+turbopack: { }object syntax with a commentexperimental.serverComponentsExternalPackagesblock (superseded byserverExternalPackagesin Next.js 15+)tsconfig.jsontomoduleResolution: bundler(the correct setting for Next.js projects, replaces deprecatednode)Hybrid agent (OpenTelemetry bridge)
This example now uses the New Relic hybrid agent instead of native Next.js instrumentation. Requires Next.js >= 16 and
newrelic >= 14.1.0.The hybrid agent routes OpenTelemetry SDK signals through the New Relic pipeline, which is the supported path for Next.js 16+. Native agent support for Next.js 14 and 15 is no longer maintained in this example (though not yet deprecated) — users on those versions should refer to the nextjs-legacy example.
Changes:
newrelic.js: enablesopentelemetry.enabled: true; disables the built-inhttp,undici, andnextinstrumentations to prevent duplicate spans when OTel instrumentations are activepackage.json: pinsnextto^16.0.0, upgradesnewrelicto^14.1.0(minimum for Next.js OTel support)-README.md: adds a version requirement callout and links tonextjs-legacyfor users on Next.js < 16Additional fixes
While validating the example against Next.js 16 / Node.js 24 (latest of each at time of writing):
require('newrelic')calls behindprocess.env.NEXT_PHASE !== 'phase-production-build'— the agent was initializing at build time and waiting indefinitely for aconnectedevent, hanging every static generation workerparams.idbeingundefinedin pages and route handlers — in Next.js 15+,paramsis a Promise and must beawaited (server components) or unwrapped withReact.use()(client components)router.refresh()to bust the router cache so the updated name is shown--loaderwith--importin thestartscript; removes--importfromdevwhere Turbopack's own ESM hooks conflict with it on Node.js 24react-domas an explicit dependencynext lint(removed in Next.js 16) toeslint .with a flateslint.config.mjsand ESLint 9Related Issues
Closes #345