Documentation for vanilla JS only? No NPM
I'm creating a webapp as a school project and I'm required to use either Supabase or Firebase but I'm limited to vanilla javascript only, meaning I have to do everything from the scratch. I think I'm on the right track, I can already kind of register (I have to check how to throw error messages on duplicate registers) and login, however I don't really know how to store the session, I don't know which key is which and a couple extra issues.
I have tried downloading an image from a bucket in my Supabase project that requires authentication without any luck yet. It works if I use the key from the Bash example, but I cannot get it to work with user data.
Some documentation would be insanely helpful, since the official documentation is written with either the NPM package in mind or Bash. I tried to read the NPM package code, but it's minified, and even if I un-minify it, it's still hard to read. Is there anything available for just vanilla Javascript?
Thanks for the help!
8 Replies
I'm not sure why npm or not is an issue for you. You can load supabase-js from a cdn and it pretty much works like it does if you where using npm.
The session is normally stored by supabase-js in local storage on a browser.
I believe all the reference guide is "plain javascript" except for the 3 installing options.
I would gladly use any of those two but we're explicitly required to do it all by ourselves I believe, I asked our professor if it was okay to install the npm package and he said "I'd prefer if you did not, you're supposed to do it all with vanilla JS"
but now that you mention it, I didn't really ask about the cdn option...
The only way to use supabase without the cdn option would be to use fetch to the API directly. I guess that is what you were doing. You could use the source to supabase-js to see what goes on, but man that is a painful way to code. If I remember firebase also had a REST API option, although I never used it.
yes, that's what I'm doing and yes it is being painful
Alot of the api is on your instance under the API tab for Bash. Basically you just have to store the return from email/password and the use that info in the authorization header for the other calls.
essentially I'm using postman to do a bunch of requests and see which does what, then forge those requests in my JS code
yeah I'm looking at the bash documentation
The best API documentation for the database calls is in PostgREST.org.
I'll give that a look! Thank you