Delete Profile

This guide will help you learn how to delete a user profile in the Next.js Supabase SaaS template, including conditions, configuration, and implementation steps.

Overview

The Next.js Supabase SaaS template provides a feature for users to delete their profiles. While this feature is available, it is not recommended in most cases due to the potential consequences, such as loss of data and access. However, the functionality remains for users who need it under specific conditions.

Conditions for Deleting a User Profile

  • Billing Status: Users can only delete their profiles if their billing has either been canceled or expired.
  • Active Subscription: If a user has an active subscription, profile deletion is not allowed.
  • Organization Members: If a user is invited to another organization by a Super Admin or Organization Owner and accepts the invitation, their profile becomes associated with that organization. If the invited user's profile is deleted, their data will also be removed from the organization's invite records.

Enabling the User Profile Deletion Feature

To display the "Delete User" option in the UI, the enableAccountDeletion flag must be set to true in the client.config.ts file under the featuresFlag section:

featuresFlag: {
    enableAccountDeletion: true,
}

Implementation Overview

When the user opts to delete their profile, the following actions are performed programmatically:

  1. Check Ownership: Verify if the user is the owner of any organizations.
  2. Delete Organizations: If the user owns any organizations, delete them.
  3. Profile Picture Removal: If a profile picture exists, it will be deleted.
  4. Delete User Account: The user’s profile is deleted from the system.
  5. Remove from Audience List: If the user is listed as part of the audience (RESEND_AUDIENCE_ID), they will be removed.

On this page