3 likes
·
3.5K reads
12 comments
Supabase is what I want to get soon, the article will help a lot, thanks for sharing this. Looking forward to learn from it.
Happy to hear this Emmanuel, Supabase is great!
Hi Ákos, thanks for posting this guide!
I wanted to check out the repo directly, but I'm getting a 404 error - can you please share an updated link?
The repo was set to private 🙈 Thanks Richard Bankole
Thanks Ákos Kőműves for the clean and easy to follow post explaining how to use Supabase, appreciate it! 🙏🏼
You're welcome Jahan, glad you found it helpful! 🙂
You mentioned a possible CRUD tutorial. I'm trying to do CRUD against supabase from my browser extension so if you could put out such a tutorial that would be great. I just put the supabase client import at the top of my popup.js file and got an error. Apparently my popup.js file is not a module and I can't put an import at the top of it. D'oh!
You might want to send whatever data you want to save in your popup.js to your backend and attempt a save from there. Yesterday, I also published my second book, which is about PWA development with React and Supabase. I'm also doing CRUD operations and setting up Supabase from scratch for crud. I currently have an ongoing promotion, and you can get the book for free. If you're interested, just send an email to support@akoskm.com.
I don't understand how did you handle the session management here. You are using getSession() method from supabase js on your background script but it can't turn anything because supabase can't initialize session on your extension on the background script.
I am using oauth client to login with my background script. I can login but I can't use any other method because supabase can't set session data to chrome.storage.local
Even tho, I explicitly refreshSession on my background script, it returns the new session but doesn't add anywhere. So it disappears in the first browser refresh. How do you keep the extension session live inside your background script? I ask this because there is no info for cross-tab session management inside extensions anywhere in the internet :)
Just because I don't have valid session stored anywhere in my background script, I can't use RLS with supabase-js. Also just because I can't use RLS I can't share my anon_key. Any ideas/opinions on this?
I don't understand how did you handle the session management here. You are using getSession() method from supabase js on your background script but it can't turn anything because supabase can't initialize session on your extension on the background script.
getSession()
returns the existing session that's persisted in localStorage after a successful await supabase.auth.signInWithPassword(value);
call.
Ákos Kőműves I know that but here's the problem. localStorage is domain based. So when you switch to different tab for different website, your extension won't persist the session. There has to be an extension wide solution which is only (as far as i imagine) possible with chrome.storage.local
Also, since you can't utilize localStorage, your background script can't use it for JS sdk. Service workers have their own runtime outside of window. If we want to have RLS active and use the database features, it's not possible extension-wide with the current session mechanism.
I wonder how you would solve those problems? I ask because mainly those are the problems that I am trying to solve but there is no proper information anywhere in the internet :)
Emre Demirel this extension is designed to work on blank.org or whatever page you specify in the manifest file.
My other extension tweton.com works only on twitter.com.
I haven't built any extensions that retain data between websites, although it would be possible with chrome.storage.local
, it wouldn't work with Firefox.
Luckily supabase's createClient
function accepts a 3rd argument where you can specify a custom storage mechanism.
It accepts an object with getItem
, setItem
, and removeItem
.
supabase.com/docs/reference/javascript/ini…
Hope this helps.