Supabase (supabase_potion v0.6.1)

The main entrypoint for the Supabase SDK library.

Starting a Client

You then can start a Client calling Supabase.init_client/3:

iex> Supabase.init_client("base_url", "api_key", %{db: %{schema: "public"}})
{:ok, %Supabase.Client{}}

Acknowledgements

This package represents the base SDK for Supabase. That means that it not includes all of the functionality of the Supabase client integrations, so you need to install each feature separetely, as:

Supabase Storage

Supabase Storage is a service for developers to store large objects like images, videos, and other files. It is a hosted object storage service, like AWS S3, but with a simple API and strong consistency.

Supabase PostgREST

PostgREST is a web server that turns your PostgreSQL database directly into a RESTful API. The structural constraints and permissions in the database determine the API endpoints and operations.

Supabase Realtime

Supabase Realtime provides a realtime websocket API powered by PostgreSQL notifications. It allows you to listen to changes in your database, and instantly receive updates as soon as they happen.

Supabase Auth/GoTrue

Supabase Auth is a feature-complete user authentication system. It provides email & password sign in, email verification, password recovery, session management, and more, out of the box.

Supabase UI

Supabase UI is a set of UI components that help you quickly build Supabase-powered applications. It is built on top of Tailwind CSS and Headless UI, and is fully customizable. The package provides Phoenix.LiveView components!

Summary

Types

Helper typespec to define general success and error returns

The available Supabase services to interact with

Functions

Creates a new one off Supabase client, you you wanna a self managed client, that levarages an [Agent][https://hexdocs.pm/elixir/Agent.html] instance that can started in your application supervision tree, check the Supabase.Client module docs.

Same as Supabase.init_client/3 but raises if any errors occurs while parsing the client options.

Types

result(a)

@type result(a) :: {:ok, a} | {:error, Supabase.Error.t()}

Helper typespec to define general success and error returns

service()

@type service() :: :database | :storage | :auth | :functions | :realtime

The available Supabase services to interact with

Functions

init_client(url, api_key, opts \\ %{})

@spec init_client(supabase_url, supabase_key, options) ::
  {:ok, Supabase.Client.t()} | {:error, changeset()}
when supabase_url: String.t(),
     supabase_key: String.t(),
     options: Supabase.Client.options()

Creates a new one off Supabase client, you you wanna a self managed client, that levarages an [Agent][https://hexdocs.pm/elixir/Agent.html] instance that can started in your application supervision tree, check the Supabase.Client module docs.

Parameters

  • base_url: The unique Supabase URL which is supplied when you create a new project in your project dashboard.
  • api_key: The unique Supabase Key which is supplied when you create a new project in your project dashboard.
  • options: Additional options to configure the client behaviour, check Supabase.Client.options() typespec to check all available options.

Examples

iex> Supabase.init_client("https://<supabase-url>", "<supabase-api-key>")
iex> {:ok, %Supabase.Client{}}

iex> Supabase.init_client("https://<supabase-url>", "<supabase-api-key>",
  db: [schema: "another"],
  auth: [flow_type: :pkce],
  global: [headers: %{"custom-header" => "custom-value"}]
)
iex> {:ok, %Supabase.Client{}}

init_client!(url, api_key, opts \\ %{})

@spec init_client!(supabase_url, supabase_key, options) :: Supabase.Client.t()
when supabase_url: String.t(), supabase_key: String.t(), options: Enumerable.t()

Same as Supabase.init_client/3 but raises if any errors occurs while parsing the client options.