script.js doesn't load with Next.js Dyamic Routes? [Error on build only]
mitchuman opened this issue · 2 comments
mitchuman commented
When using Next.js Dynamic Routes (setup found here and just below), /_vercel/insights/*
does not seem to get included in the build, thus the analytics scripts aren't running.
Setup: /app/[slug]/page.tsx
Notice the usage of notFound()
and generateStaticParams()
that likely disable generated routes that aren't included in the fetched data, including /_vercel/*
export default async function Page({ params }: Props) {
const page = await getPage(params)
if (!page) notFound()
return <>...</>
}
export async function generateMetadata({ params }: Props) {
const page = await getPage(params)
if (!page) notFound()
return { ... }
}
export async function generateStaticParams() {
const slugs = await fetchData(...)
return slugs.map((slug) => ({ slug }))
}
tobiaslins commented
Hey!
Vercel Analytics only works when deployed on Vercel (or when running dev).
mitchuman commented
Ok I see it running now when I deploy on the live branch. TY