How do I use Drizzle with Supabase an Expo?

I’m trying to figure out how to use Drizzle with Expo React Native and Supabase. I know there’s a package that’s made for Expo but it’s for ExpoSQLITE. Could I install the regular drizzle package and set it up normally for Supabase? Or would that make my app vulnerable because all the queries are happening locally on device. Thanks in advance
6 Replies
Donda_HQ
Donda_HQ6mo ago
dont know if this will help but i was able to configure Supabase and Drizzle for my Expo project , i used this doc to make it work and a little bit of gpt : https://supabase.com/docs/guides/database/connecting-to-postgres#connecting-with-drizzle
Connecting to your database | Supabase Docs
Explore the options for connecting to your Postgres database.
Donda_HQ
Donda_HQ6mo ago
Drizzle ORM - Drizzle with Supabase Database
Drizzle ORM is a lightweight and performant TypeScript ORM with developer experience in mind.
salzar
salzarOP6mo ago
Oh so it does work with expo? I remember it being a whole thing where you couldn’t because you needed server sided for security
Donda_HQ
Donda_HQ6mo ago
Yes it does work , I was able to define my models and migrate them to my supabase db But at the moment on my project I’m stuck with this weird bug I can’t seem to fix
rphlmr ⚡
rphlmr ⚡6mo ago
You can, but I strongly discourage it because it requires your root password in the connection string. Nothing is secret in a mobile app; it's like using your secrets in client code on a web app. To make it secure, Supabase with its SDK provides a system with an Anon key and Row Level Security (RLS) policies that you have to enable on each table. These policies define what a given user can do on the table. The SDK forwards all your requests through an API hosted by Supabase that relies on PostgREST. Drizzle is working on RLS support, but you should know that a database has a limited number of simultaneous connections. Hopefully, Supabase provides a way to bypass this limitations: Supavisor. So, I would advise using a server (it's easier to fix query bugs without releasing a new app version and waiting for store review, even if you have over-the-air updates with Expo). I can understand you prefer to avoid the server, so maybe you can follow one of the solutions shared here https://github.com/drizzle-team/drizzle-orm/discussions/2450
GitHub
[FEATURE]: Support PostgreSQL's Row Level Security (RLS) · drizzle-...
Describe want to want Supabase is really nicely using Row Level Secruity for granular authorization rules. 🔗 Here's the link to their docs: https://supabase.com/docs/guides/auth/row-level-secur...
salzar
salzarOP6mo ago
I appreciate the response thank you
Want results from more Discord servers?
Add your server