Supabase (Supabase v0.2.2) View Source

Elixir library for Supabase.

Combines Supabase Auth, provided by gotrue-elixir, Supabase Database/Rest, via postgrestex, and Supabase Storage, implemented in this library.

Once you configured your application

config :supabase,
  base_url: <supabase-url>
  api_key: <supabase-anon-key>

you can initiate the usage of the different services with

Auth

Supabase.auth()
|> GoTrue.get_user(access_token)

Database

Supabase.rest(access_token)
|> Postgrestex.from("profiles")
|> Postgrestex.eq("user_id", "1")
|> Postgrestex.call()

Instead of Postgrestex.call(), supabase-elixir provides a Supabase.json/2 function to directly parse the response to a map or struct.

Supabase.rest(access_token)
|> Postgrestex.from("profiles")
|> Postgrestex.eq("user_id", "1")
|> Supabase.json(keys: :atoms)

Storage

Supabase.storage(access_token)
|> Supabase.Storage.from("avatars")
|> Supabase.Storage.list()

Link to this section Summary

Functions

Returns a client that can be used for functions of the GoTrue library.

Entrypoint for the Postgrest library

Entry point for the Storage API

Entry point for the Storage API for usage in a user context

Link to this section Functions

Returns a client that can be used for functions of the GoTrue library.

Example

iex> Supabase.auth() |> GoTrue.settings()
%{
  "autoconfirm" => false,
  "disable_signup" => false,
  "external" => %{
    "azure" => false,
    "bitbucket" => false,
    "email" => true,
    "facebook" => false,
    "github" => true,
    "gitlab" => false,
    "google" => false,
    "saml" => false
},
  "external_labels" => %{}
}
Link to this function

init(base_url, api_key, options \\ [])

View Source
Link to this function

json(request, options \\ [])

View Source

Specs

json(map(), keyword()) :: %{body: map() | list(), status: integer()}

Entrypoint for the Postgrest library

Example

Supabase.rest(access_token)
|> Postgrestex.from("profiles")
|> Postgrestex.call()
Link to this function

rest(access_token, options)

View Source

Entry point for the Storage API

Entry point for the Storage API for usage in a user context

Example

Supabase.storage(access_token)
|> Supabase.Storage.from("avatars")
|> Supabase.Storage.download("avatar1.png")