Speed Insights not working with SvelteKit app

Hi,

I have followed all the steps in the Speed Insights Quickstart:

  • I have enabled Speed Insights in my Project Settings.
  • I have installed the @vercel/speed-insights package.
  • I have added a /src/routes/+layout.ts file to my SvelteKit app:
import { injectSpeedInsights } from '@vercel/speed-insights/sveltekit';
 
injectSpeedInsights();
  • I have committed and pushed that change to my repo at Github and can see that it was deployed to Vercel in my project’s “Deployments” tab.

But, for some reason, I do not see the /_vercel/speed-insights/script.js script inside the body tag of any page on my site.

I do have a server-side +layout.server.ts file as well as a universal +layout.ts, but, according to the SvelteKit docs, this should be OK: " If a route contains both universal and server load functions, the server load runs first."

I previously tried calling injectSpeedInsights() in my server-side +layout.server.ts, and, strangely, it worked for a little while, and I got some initial Speed Insights data, but it has since stopped working.

I feel like I’m missing something obvious, so any suggestions on how to troubleshoot this would be very welcome.

Thanks in advance,
Michael

Hey @michaelyoon. Do you have a minimal reproducible example I can use to investigate what’s going wrong? I wasn’t able to repro it with my test app, so I’m wondering if there’s another feature interfering. Would be good for us to work from the same code to debug this :slightly_smiling_face:

Hi @amyegan, thanks for getting back to me. I’ll see if I can put one together and get back to you ASAP.

1 Like

Hi again, it looks like Speed Insights is now working for me. Maybe it just took some time for the data to show up?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.