JavaScript not working locally

JavaScript can make a preview interactive, but it can also depend on build tools or server features.

The problem

Modern projects use modules, bundlers, API calls or framework routers. If the source folder is opened instead of the finished export, built files may be missing. Some browser features are also restricted locally. SitePreviewKit keeps uploaded code inside a sandboxed iframe.

Simple solution

  1. Check whether a dist, build or out folder exists.
  2. Review script tags and confirm that linked files are included.
  3. Separate static interactions from server-backed features.
  4. Comment on issues before changing JavaScript.
  5. Test critical interactions again in the real deployment environment.

Common mistakes

Checklist

FAQ

Why do API features not work locally?

A static preview has no server. API routes, databases and logins need another environment.

Does SitePreviewKit execute JavaScript?

Uploaded site JavaScript runs only inside the sandboxed preview, not in the host app DOM.

Should I edit JavaScript in the code editor?

Only if you know what you are doing. Changes stay local but can affect the preview.

Related guides