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
- Check whether a dist, build or out folder exists.
- Review script tags and confirm that linked files are included.
- Separate static interactions from server-backed features.
- Comment on issues before changing JavaScript.
- Test critical interactions again in the real deployment environment.
Common mistakes
- Uploading package.json and expecting npm to run automatically.
- Testing API features without a backend.
- Forgetting JavaScript files in the export.
- Confusing external script errors with site errors.
Checklist
- Finished build uploaded
- JS files included
- No required API routes for static preview
- Browser console checked
- Navigation and forms tested realistically
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.