I am trying to import JS for navigation into my Astro project. The error I get is “Browser APIs are not available on the server.
If the code is in a framework component, try to access these objects after rendering using lifecycle methods or use a client:only directive to make the component exclusively run on the client.
See https://docs.astro.build/en/guides/troubleshooting/#document-or-window-is-not-defined for more information.”
The script does use both window and document. However I am unsure how to import the script outside the frontmatter.
Thanks a lot.
I have tried importing the script and am using:
import ‘../js/menu.js’;
inside Header.astro.
However I cannot figure out how to import it outside of the frontmatter.
Thanks