Back

[SOLVED] Window is not defined when running in SvelteKit using Adapter Static

  • 0
  • General
  • Web
Omnificent
22 Mar, 2023, 04:25

Hey guys, I'm trying out SvelteKit with Appwrite and using @sveltejs/adapter-static. I'm getting a error of 'window is not defined' when I run 'npm run dev'.

I have added export const prerender = true; in +layout.js in the root of routes folder.

Not sure what is wrong. Would like for some assistance or guidance on this.

Thanks in advance!

TL;DR
The user was experiencing an error stating that 'window is not defined' when running their SvelteKit project with the Adapter Static. They mentioned that they had added `export const prerender = true;` in the +layout.js file in the root of the routes folder. The issue was resolved when the user realized they had imported some extra Appwrite functions that were causing the problem. The solution was to remove the unnecessary imports. It was mentioned that using realtime functionality could be problematic with the static adapter and pre-renders, so the user was advised to keep that in mind for future reference.
Drake
22 Mar, 2023, 04:29

What exactly is throwing this?

Meldiron
22 Mar, 2023, 09:38

Are you using realtime functionality? That might be problematic with static adapter and pre-renders.

Omnificent
22 Mar, 2023, 16:51

Ahh sorry for the late reply. Didn't get notified.

Anyways, I fixed the problem. I imported in some extra Appwrite functions which I wasn't using and it was causing some issues.

Haven't tried realtime yet but will keep in mind if I come across this again. Thanks!

Drake
22 Mar, 2023, 17:10

[SOLVED] Window is not defined when running in SvelteKit using Adapter Static

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more