ReferenceError: indexedDB is not defined

I have an issue with my local development setup that I didn’t have last night but I’m not sure what I have changed that could have caused it.

I also now get an errors in my vite config:

Any help appreciated.



Ok the vite config error appears to be fixed by running:
npm install --save-dev @types/node

But not sure what I did to remove this.

As you can see I still get the indexed db error.

Ok so my error comes from me trying to sync my auth store immediately on initialisation

Removing this has got things loading locally again.

Something I only did to try and stop the reload my navbar between page navigation. I will continue to investigate the correct way to fix that.

Good catch :+1:

Server Side Generation (SSG), using the static adapter in SvelteKit, implies that the framework attempts to pre-render your app on a pseudo server-side environment where there is no IndexedDB (IDB). An API which is only available in the browser.

If you have code related to AuthClient, that is executed directly when your app boots, the pre-rendering process will fail because it will try to execute per extension IndexedDB (used by AuthClient) given that the API is not available in the server-side environment, therefore the error ReferenceError: indexedDB is not defined.

To address this issue, if you must execute a piece of code that requires IDB when your app boots in the browser, you can use the browser env flag provided by SvelteKit to ensure that the code is executed only in the browser.

1 Like