Supabase.GoTrue.LiveView (supabase_gotrue v0.3.10)

Provides LiveView integrations for the Supabase GoTrue authentication in Elixir applications.

This module enables the seamless integration of authentication flows within Phoenix LiveView applications by leveraging the Supabase GoTrue SDK. It supports operations such as mounting current users, handling authenticated and unauthenticated states, and logging out users.

Configuration

The module requires some application environment variables to be set:

  • authentication_client: The Supabase client used for authentication.
  • endpoint: Your web app endpoint, used internally for broadcasting user disconnection events.
  • signed_in_path: The route to where socket should be redirected to after authentication
  • not_authenticated_path: The route to where socket should be redirect to if user isn't authenticated ## Usage Typically, you need to define a module to be your LiveView Authentication entrypoint and use this module to inject the necessary functions that you will use on yourMyAppWeb.Router, to handle user authentication states through a series ofon_mountcallbacks, which ensure that user authentication logic is processed during the LiveView lifecycle. Checkon_mount/4` for more detailed usage instructions on LiveViews ### Example defmodule MyAppWeb.Auth do use Supabase.GoTrue.LiveView, endpoint: MyAppWeb.Endpoint, client: MyApp.Supabase.Client, signed_in_path: "/app", not_authenticated_path: "/login" end