zoedsoupe
Hello alchemists! I’m here to present about a new way to interact with Supabase services: supabase-potion made with love and magic by @zoedsoupe ![]()
What it is?
supabase-potion is a client library that provides a developer-friendly interface to interact with various of Supabase services. It highly integrates with OTP, meaning that it can handle thousands of different clients/connections.
It also provides friendly error messages and error return from all functions, meaning that you can simply pattern match on all pre-discovered error messages/error codes from Supabase APIs.
Finally, the idea behind this client library is to provide a similidar API as those other Supabase clients for Go,Javascript, Rust and other, in the meaning of quality, folowwing good practices of the language itself and provide a composable interface.
Why another Supabase client library?
There is also some offical attempts to provide Supabase integration in the elixir world, like:
Which are awesome libraries! However they have some negative points, like:
- doesn’t provide a friendly way to integrate each library with each other
- doesn’t use OTP benefits, supervision trees or concurrency, they seem to be done on a scripint language
- packages seem to be unmaintained/have no more updates
- Supabase Realtime and UI (for Live View) are missing implementation
- GoTrue is missing some important functions and doesn’t have integration with Plug and Live View hooks
- Storage implementation is incomplete and doesn’t support uploads/downloads with async/streams
- PostgREST is missing a bunch of functions and doesn’t integrate with
ecto
So seeing these points I decided to create my own client library and share with others who would like to test/use Supabase services from our Phoenix applications or other future libraries.
What is currently done?
Supabase Potion
Where all starts! Define client management with DynamicSupervisor and the basic strucutre to interact with other services!
init_client/1init_client!/1
To start a client, if the library itself is managing clients, you can safely use:
iex> Supabase.init_client %{name: MyClient}
{:ok, #PID<1.2.3>}
You can also mannually start/manage clients with:
iex> Supabase.Client.start_link(%{name: MyClient})
{:ok, #PID<1.2.3>}
Supabase Storage
The file storage service from Supabase, now completely available to Elixir/Phoenix users! All these functions receive a Supabase.Client definition (either an atom or a pid).
- the implementation is complete, handles async uploads and downloads from buckets!
- complete mapping of entities like
%Object{}and%Bucket{}
The complete list of current functions are:
Buckets
list_buckets/1retrieve_bucket_info/2create_bucket/2update_bucket/2empty_bucket/2delete_bucket/1
Objects
remove_object/3move_object/4copy_object/4retrieve_bucket_info/3list_objects/4upload_object/5download_object/3download_object_lazy/3save_object/3save_object_stream/3create_signed_url/4
Supabase Auth/GoTrue
Provide authentication via:
- email+password
- oauth
- otp codes
- magic links
Also integrates for authentication with Plug and Live View hooks!
Current functions are:
User API
get_user/2sign_in_with_password/2sign_up/2
Admin API
sign_out/3invite_user_by_email/3create_user/2generate_link/2delete_user/3get_user_by_id/2list_users/2update_user_by_id/3
Plugs
VerifyHeader
Roadmap
GoTrue/Auth
- Finish integration (User API)
- Implement
VerifyCookiePlug - Implement
VerifySessionPlug - Implement
:ensure_authenticatedLive View hook - Implement
:redirect_if_authenticatedLive View hook - Implement
:mount_current_userLive View hook
Supabase UI
- Provide function components for Live View
- Provide Live components for Live View
- Provide Auth ready-to-use components for Live View
Supabase PostgREST
- Generate schemas/migrations based on Supabase database schema
- Provide an way to integrate with
ectoviaEcto.Adapter(it’s being discussed in this thread)
Supabase Realtime
- Provide PubSub adapter for realtime messages
- Provide Process Messaging adapter to send to whole system
Conclusion
That’s it! I’m really proud of this client library and I really would like people to use, test and contribute in any way to the project! It stills on high development, so expect breaking changes. There are always something to improve, so I’m open to any kind of contribution such as: testers, documentation, code review, feature request and other types of contribution.
Trending in Announcing
Other Trending Topics
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
hauleth
404 on repo
zoedsoupe
Sorry i did a typo on the github repo link. I already fixed it!
The complete link is GitHub - zoedsoupe/supabase: The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications. · GitHub
zoedsoupe
i have some good news! I just launched new updated and refactored versions for the aforementioned hex packages, targeting the base SDK (aka
supabase-ex) implementation.to summarize, i simplified the client initialization and move the decision to manage OTP processes for the final user, as it should be! this should also prevent strange errors on starting and using clients but also clarify the documentation on how to start a client, as in the later version it had around 3 ways to start a client…
so basically, the current state for each library and my current roadmap is (very summarized):
supabase-ex
supabase-jspostgrest-ex
postgrest-jsandpostgrest-gowith composable and “lazy” query and filter buildersstorage-ex
gotrue-ex
Roadmap
Said that, i would like to tackle these next features:
Phoenix.LiveViewPubSuband or process messaging to receive updates, besides the API integrationgotrue-exgotrue-exeasily on
postgrest-exWojciech
Nice project, how easy is it to migrate from postgresql and MinIO(S3) to selfhosted supabase? Currently i use req_s3 for interacting with s3 and traditional setup for postgres, if i use your library do i have to switch to your solution for s3 interactions? I would also appreciate any example projects if you have any
Thanks for your work!
zoedsoupe
So cool! Let’s break on smaller parts:
From the beginning: Supabase is an open source alternative for Firebase but it do can be used from backend servers
PostgreSQL
Supabase offers a dedicated postgresql instance that you can interact with many ways. For elixir/phoenix applications i really recommend to just grab the connection config and link directly with Ecto!
but if eventually you would like to test or build only a “client side app” with live view, you could use the
postgrest-exlibrary that interact with your database instance via HTTP (trough PostgREST project)MinIO/object storages
Supabase also offers the Supabase Storage feature, the good news is that it supports the S3 protocol, so you don’t need to use
storage-ex, you can use directlyreq_s3or evenex_awsfor S3 servicesSelf hosting
You can easily self host supabase instances based on their docker-compose, like said is this tutorial: Self-Hosting | Supabase Docs
Conclusion
This library aims to provide an easy, plug n play way to interact with supabase! Also, i do want to build example applications to demonstrate each integration, that’s on the roadmap too
Wojciech
Thanks