Skip to content

Running analytics in both App and Pages router. #194

@kobeaerts-dep

Description

@kobeaerts-dep

Hey, we are running into issues with the speed-insights and analytics packages.
We are running both the pages and app router in the same project.

For the app router we can import both from the analytics/next package and everything works. When we do the same for the pages router we get the following error:

Error: Failed to load external module @vercel/speed-insights-bcbcb3a010496fd7/next: Error: Cannot find module 'next/dist/server/route-modules/pages/vendored/contexts/app-router-context'
Require stack:
- /var/task/node_modules/next/dist/client/components/navigation.js
    at Context.externalImport [as y] (.next/server/chunks/ssr/[turbopack]_runtime.js:518:15)
    at async (.next/server/chunks/ssr/[root-of-the-server]__7b0c281d._.js:1:54)

https://cleanshot.com/share/8vWvkr8q [blocked]

Both packages do work in our pages router if we import from the /react version.

SpeedInsights & Analytics are on v2.0.0
Next.js version is 16.1.6

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions