Astro + Svelte + Internet Identity; AuthClient problem - indexedDB.open

I am trying to integrate Internet Identity into an Astro static website. I am using Svelte in an Astro Island.

When I run it with the dev server, everything works fine, but when I try to build the Astro project, I get the following error:

15:15:18 :arrow_forward: src/pages/member.astro
15:15:18 └─ /member/index.html/…node_modules/@dfinity/auth-client/node_modules/idb/build/index.cjs:15
const request = indexedDB.open(name, version);
^

ReferenceError: indexedDB is not defined
at openDB (…node_modules/@dfinity/auth-client/node_modules/idb/build/index.cjs:15:21)
at _openDbStore (…node_modules/@dfinity/auth-client/lib/cjs/db.js:14:35)
at IdbKeyVal.create (…node_modules/@dfinity/auth-client/lib/cjs/db.js:54:26)
at …node_modules/@dfinity/auth-client/lib/cjs/storage.js:88:28
at new Promise ()
at get _db [as _db]
Node.js v18.17.1

Any idea what the problem might be? Thanks for any help!

There is no IDB in NodeJS context, your build is probably failing at the pre-rendering stage.

Uh, you are completely right. There was an error in the pre-rendering, sorry. :unamused:

1 Like