Skip to content

Sign-in persistantce #215

Open
Open

Description

@eduardoagr

Feature request

Is your feature request related to a problem? Please describe.
I'm using Supabase in a .NET MAUI application, and currently there's no built-in way to persist the user session across app restarts. This creates friction in the user experience, as I have to manually store the user's email and encrypted password in SecureStorage and re-authenticate using SignInWithEmailAndPassword every time the app launches. I attempted to use Client.RefreshToken, but this method doesn’t accept any parameters and doesn’t restore the session as expected.

A clear and concise description of what you want and what your use case is.

Describe the solution you'd like

I propose introducing a UserRepository abstraction that can be registered with the MAUI dependency injection system. This repository would internally handle session persistence, token refresh, and automatic re-authentication — similar to how FirebaseDatabase.net manages user state. The goal is to make session management seamless for developers, so they don’t have to manually store credentials or manage refresh logic. The library should automatically restore the session if a valid token is available.

A clear and concise description of what you want to happen.

Describe alternatives you've considered

  • Manually storing email and encrypted password in SecureStorage and calling SignInWithEmailAndPassword on app launch.
  • Attempting to use Client.RefreshToken, which currently lacks the necessary parameters or behavior to restore a session.
  • Building a custom wrapper around Supabase client to simulate session persistence, which adds unnecessary complexity and maintenance overhead.

Additional context

This feature would greatly improve developer experience and app security by abstracting session management. It aligns with best practices seen in other libraries like Firebase, and would make Supabase more accessible for MAUI developers building production-grade apps.

Add any other context or screenshots about the feature request here.

Activity

  1. added
    feature
    on Nov 11, 2025
  2. kallebysantos commented on Nov 30, 2025

    @kallebysantos
    Member

    I believe that a correct approach should to implement an AuthenticationStateProvider or similar.
    .NET already owns a lot of Auth features that can be customised via DI, this way we can natively integrate with Supabase.

  3. FozerG commented on Jan 1, 2026

    @FozerG

    I don’t understand why you are storing the user’s password and calling SignInWithEmailAndPassword on every app launch.
    This should not be necessary. The correct approach is to persist the access_token and refresh_token and restore the session using Client.Auth.SetSession(accessToken, refreshToken).

    Re-authenticating with email and password on startup is both unnecessary and less secure, since Supabase already provides refresh tokens specifically for session restoration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions