Home > Back-end >  Sveltekit with Superbase __api not defined
Sveltekit with Superbase __api not defined

Time:02-26

I have successfully run superbase with svelte using this tutorial . However I really need the sveltkit rather than basing it on the svelte template . When I try to use superbase based on a sveltkit project I get the following error

11:50:01 [vite] Error when evaluating SSR module /src/superbaseClient.js:
ReferenceError: __api is not defined
    at /src/superbaseClient.js:3:21
    at async instantiateModule (/Users/bob/Documents/dev/javascript/svelte/svelteBp/node_modules/vite/dist/node/chunks/dep-971d9e33.js:56177:9)
11:50:01 [vite] Error when evaluating SSR module /src/routes/sbase.svelte:
ReferenceError: __api is not defined
    at /src/superbaseClient.js:3:21
    at async instantiateModule (/Users/bob/Documents/dev/javascript/svelte/svelteBp/node_modules/vite/dist/node/chunks/dep-971d9e33.js:56177:9)
__api is not defined
ReferenceError: __api is not defined
    at /src/superbaseClient.js:3:21
    at async instantiateModule (/Users/bob/Documents/dev/javascript/svelte/svelteBp/node_modules/vite/dist/node/chunks/dep-971d9e33.js:56177:9)

I have tried

  1. Created a new sveltkit project using the sveltkit getting started instructions
  2. Followed the getting started instructions in superbase but replaced the use of the svelte template with a sveltekit project.
  3. When I first saw it didn't work I then compared the package.json of both my svelteSuperbase project and the sveltekitSuperbase project and then made the note working project include all all the dependencies from both in the project. It was a bit hacky and didn't work.
  4. Looked online and found one article which mentioned changing the rollup.config.js file which I did accoridng to the instructions but it did not work.

More code is available for the whole project on the github. The code with all my failed attempts at getting it to work can be found in a branch on that repo called "add superbase"

CodePudding user response:

You can try the Supabase Adder: https://github.com/supabase-community/svelte-supabase

  • Related