App Store
Rejected under Guideline 5.1.1(v) for missing account deletion: how to add it to a Supabase app
If people can create an account in your app, Apple requires that they can also start deleting it inside the app - deactivation is not enough. In a Supabase app that means a button in the app, a small server-side function that removes the user's files and the Auth user, and foreign keys that remove the rest of the user's rows with them. Guideline text below is quoted from the version last updated on 2026-10-16.
What you are seeing
The rejection arrives in App Store Connect, on the App Review page of your app. It cites Guideline 5.1.1(v) (part of 5.1.1 Data Collection and Storage, in the Legal section) and says the app supports account creation but does not let people delete their account. Read the full message, not the notification email - the wording varies. Situations that lead to it:
- The app has a sign-up screen and no "Delete account" option anywhere.
- There is a delete option, but it only deactivates the account, signs the user out, or opens an email to support.
- The delete button removes the profile row, but the user can still sign in afterwards because the Supabase Auth user was never deleted.
- Account creation happens on your website or in the default browser, and the app itself has no deletion option. Apple's guidance says the app still needs one (5.1.1(v) guidance).
- The app creates accounts automatically, for example a guest session with Supabase
signInAnonymously(), which creates a real user in Auth (Anonymous Sign-Ins). Apple says people must be able to delete those too.
How to check it yourself
First, what Apple actually requires. The rule itself is one sentence inside Guideline 5.1.1(v), Account Sign-In:
“If your app supports account creation, you must also offer account deletion within the app.”
Apple's account deletion guidance spells out what counts. In short:
- The option must be easy to find in the app - typically in account settings.
- It must offer to delete the whole account record with the associated personal data. Only offering to deactivate or disable the account is not enough.
- If deletion is finished on your website, the app must link directly to that page, not to your home page or privacy policy.
- Outside highly regulated industries, the app should not make people call, email or chat with support to delete their account.
- Confirmation steps and re-authentication are allowed, but making deletion unnecessarily difficult will not pass review.
- Deletion does not have to be instant. If it takes time, tell the person how long and confirm when it is done.
- Content the person shared with others (photos, posts, reviews) is part of the data that should go. If the law requires you to keep some data, say what you keep.
- Complying with GDPR or CCPA in some countries is not enough: everyone, wherever they are, must be able to delete their account.
Then check your own app and your own Supabase project. All of the queries below are read-only.
1. Is there a deletion flow at all, and where does it run?
Search the project for anything that deletes users. Run this from the project root (for an app built with an AI tool, from the repository it synced to GitHub):
grep -rnE "deleteUser|delete-account|delete_account|deleteAccount" \
--exclude-dir=node_modules --exclude-dir=.git .auth.admin.deleteUser is a different problem - see the next paragraph.Deleting a Supabase Auth user needs a secret or service_role key, and Supabase says that call belongs on a server only (deleteUser reference). If the delete button works because a secret key sits in the app's code, every user of the app holds a key that bypasses all your database rules. Our guide on open Supabase tables shows how to search the build for leaked keys.
2. What happens to each table when a user is deleted?
Your data lives in your own tables, which point at the user through columns such as user_id. Whether those rows disappear with the user is decided by the foreign key on each column. In the Supabase dashboard open SQL Editor and run:
select
conrelid::regclass as from_table,
confrelid::regclass as to_table,
conname as constraint_name,
case confdeltype
when 'c' then 'cascade'
when 'n' then 'set null'
when 'd' then 'set default'
when 'r' then 'restrict'
when 'a' then 'no action'
end as on_delete,
pg_get_constraintdef(oid) as definition
from pg_constraint
where contype = 'f'
and connamespace = 'public'::regnamespace
order by confrelid::regclass::text, conrelid::regclass::text;pg_constraint catalog.to_table = auth.userswithcascade: the rows go when the user goes. This is what Supabase's own example for aprofilestable uses (User Management).no actionorrestrictpointing atauth.users: deleting a user who has rows in that table fails with a foreign key error. PostgreSQL documentsno actionas the default when nothing is specified (PostgreSQL: constraints).set null: the rows stay, without an owner. Fine for records you must keep (see the fix), not for personal data.- A table pointing at
public.profilesinstead ofauth.usersis fine if its own key cascades andprofilescascades fromauth.users- follow the chain to the end.
Then look for columns that hold a user's id but have no foreign key at all. Their rows will not fail the deletion and will not be removed either - they are simply left behind:
select c.table_name, c.column_name
from information_schema.columns c
join information_schema.tables t
on t.table_schema = c.table_schema
and t.table_name = c.table_name
and t.table_type = 'BASE TABLE'
where c.table_schema = 'public'
and c.data_type = 'uuid'
and c.column_name in ('user_id', 'owner_id', 'created_by', 'author_id', 'profile_id')
and not exists (
select 1
from pg_constraint k
join pg_attribute a
on a.attrelid = k.conrelid
and a.attnum = any (k.conkey)
where k.contype = 'f'
and k.conrelid = format('%I.%I', c.table_schema, c.table_name)::regclass
and a.attname = c.column_name
)
order by c.table_name, c.column_name;3. Does the user own files in Storage?
Supabase records who uploaded each file in the owner_id column of storage.objects (Storage ownership), and it will not delete an Auth user who still owns files: the deletion fails with an error (User Management). Pick a test user from Authentication > Users, copy their user ID, and run:
select bucket_id, count(*) as files
from storage.objects
where owner_id = 'PASTE-THE-TEST-USER-ID'
group by bucket_id
order by bucket_id;4. Anything outside Supabase?
- Sign in with Apple: Apple's guidance says to revoke the user's tokens with the Sign in with Apple REST API when they delete their account (revoke tokens).
- Auto-renewable subscriptions through in-app purchase: billing continues through Apple until the person cancels, whether or not they delete the account (Human Interface Guidelines: Managing accounts).
- Stripe, email marketing, analytics or AI providers that received the user's personal data: list them, because the deletion flow should cover them too.
Why it happens
Sign-up is the first thing an app needs and deletion is the last thing anyone thinks of, so a generated app usually gets the first and not the second. On a website nobody checks. App Review does: a reviewer who creates an account and cannot find a way to delete it has found a 5.1.1(v) rejection.
Supabase adds three reasons why a quick fix does not work:
- The app cannot delete its own user from the browser or the phone.
auth.admin.deleteUser()requires a secret key and must only run on a server (deleteUser reference). So the button has to call something server-side, such as an Edge Function. - Deleting your own rows is not deleting the account. Supabase is explicit: marking an account as deleted only in your application tables leaves the Auth user intact, so it can still sign in, and a temporary ban does not revoke existing sessions either (User Management).
- Files and foreign keys get in the way. A user who owns Storage objects cannot be deleted until the files are gone, and a foreign key without
on delete cascadeeither blocks the deletion or leaves orphaned rows.
How to fix it
Step 1: make the database clean up after the user
For every table from check 2 that holds personal data, the foreign key to the user should cascade. Replace the existing constraint, using the name the query returned:
alter table public.orders
drop constraint orders_user_id_fkey,
add constraint orders_user_id_fkey
foreign key (user_id) references auth.users (id) on delete cascade;For columns from the second query that had no foreign key, add one without the drop line: alter table public.orders add constraint orders_user_id_fkey foreign key (user_id) references auth.users (id) on delete cascade;. If adding it fails, the table already contains rows whose user no longer exists. Find them before deciding what to do with them:
select count(*)
from public.orders o
where o.user_id is not null
and not exists (select 1 from auth.users u where u.id = o.user_id);Reference auth.users (id), its primary key, and nothing else in that table - Supabase recommends only primary keys as references to tables it manages (User Management). If you must keep some records, for example invoices for tax purposes, use on delete set null on a nullable column for that table instead, and tell users in the app which data you keep and why. Whether you have to keep it is a legal question - check it with whoever advises you.
Step 2: an Edge Function that deletes the account
Create the function with the Supabase CLI (supabase functions new delete-account) and replace the generated supabase/functions/delete-account/index.ts with the code below. It uses withSupabase from @supabase/server, the wrapper Supabase's Edge Function auth guide documents: with auth: 'user' the function only runs for a signed-in user, ctx.userClaims.id is that user's ID taken from their verified token, and ctx.supabaseAdmin is the server-side client with the secret key, which never leaves the server.
import { withSupabase } from "npm:@supabase/server@1";
import type { SupabaseClient } from "npm:@supabase/supabase-js@2";
// Buckets where each user's files live in a folder named after their user ID,
// e.g. avatars/<user-id>/photo.png. Change this list to match your project.
const USER_BUCKETS = ["avatars", "uploads"];
const PAGE_SIZE = 100;
const REMOVE_BATCH = 1000; // Storage removes at most 1000 files per call
async function listFiles(admin: SupabaseClient, bucket: string, folder: string): Promise<string[]> {
const paths: string[] = [];
for (let offset = 0; ; offset += PAGE_SIZE) {
const { data, error } = await admin.storage.from(bucket).list(folder, { limit: PAGE_SIZE, offset });
if (error) throw error;
for (const item of data) {
const path = folder + "/" + item.name;
// Folders come back with id === null; look inside them too.
if (item.id === null) paths.push(...(await listFiles(admin, bucket, path)));
else paths.push(path);
}
if (data.length < PAGE_SIZE) return paths;
}
}
async function deleteUserFiles(admin: SupabaseClient, userId: string): Promise<void> {
for (const bucket of USER_BUCKETS) {
const paths = await listFiles(admin, bucket, userId);
for (let i = 0; i < paths.length; i += REMOVE_BATCH) {
const { error } = await admin.storage.from(bucket).remove(paths.slice(i, i + REMOVE_BATCH));
if (error) throw error;
}
}
}
export default {
fetch: withSupabase({ auth: "user" }, async (req, ctx) => {
if (req.method !== "POST") {
return Response.json({ error: "Method not allowed" }, { status: 405 });
}
const userId = ctx.userClaims?.id;
if (!userId) {
return Response.json({ error: "Not signed in" }, { status: 401 });
}
try {
// 1. Third-party data (Stripe customer, Sign in with Apple tokens...) goes here.
// 2. Files first: Supabase will not delete a user who still owns Storage objects.
await deleteUserFiles(ctx.supabaseAdmin, userId);
// 3. The Auth user. Foreign keys with ON DELETE CASCADE remove the user's rows.
const { error } = await ctx.supabaseAdmin.auth.admin.deleteUser(userId);
if (error) throw error;
return Response.json({ deleted: true });
} catch (err) {
console.error("delete-account failed for user", userId, err);
return Response.json({ error: "Account deletion failed. Please try again." }, { status: 500 });
}
}),
};Deploy it to your project (Deploy to Production):
supabase link --project-ref YOUR-PROJECT-REF
supabase functions deploy delete-accountdeleteUserFiles, and use the Storage query from check 3 to see what is left. If the user still owns a file anywhere, deleteUser returns an error instead of deleting the account.Step 3: the button in the app
Put "Delete account" in the account or settings screen, where Apple expects it. Ask for confirmation, say what will be deleted, and only then call the function:
async function deleteAccount(): Promise<boolean> {
const { error } = await supabase.functions.invoke("delete-account", { method: "POST" });
if (error) {
showError("We could not delete your account. Please try again or contact us.");
return false;
}
// The user no longer exists on the server; clear the session on this device.
await supabase.auth.signOut({ scope: "local" });
return true;
}showError stands for however your app shows messages. On success, show a screen that confirms the account was deleted.supabase.functions.invoke sends the signed-in user's token with the request, which is how the function knows whose account to delete. signOut({ scope: 'local' }) removes the session from this device; the default scope is global, which signs the user out everywhere (signOut reference).
Step 4: subscriptions, Sign in with Apple and other services
- In-app subscriptions: before the final confirmation, tell the person that billing continues through Apple and ask them to cancel first. Apple's guidance points to
showManageSubscriptionson iOS 15 and later, or the linkhttps://apps.apple.com/account/subscriptions/(5.1.1(v) guidance). You may offer to schedule deletion for when the subscription ends, but only alongside an option to delete immediately. - Sign in with Apple: revoke the user's Apple tokens by calling
POST https://appleid.apple.com/auth/revokewith your client ID, a client secret and the user's refresh or access token (revoke tokens). Supabase's Sign in with Apple guide does not describe this step, so check whether your setup keeps a token you can revoke before relying on it. - Stripe: if the user is a Stripe customer, deleting the customer is permanent and immediately cancels their active subscriptions (Stripe API). Decide whether that is what you want, or whether you cancel subscriptions and keep billing records you are required to keep.
Step 5: test it like a reviewer, then verify
- Create a fresh test account in the app, add some data and upload a file.
- Find the "Delete account" option without help and delete the account. Count the taps - Apple asks for a straightforward process.
- Try to sign in again with the same account. It must fail as an unknown user (or create a brand new, empty account).
- In the dashboard, check that the user is gone from Authentication > Users.
- Rerun the Storage query from check 3 with the deleted user's ID: it should return no rows.
- Count the user's rows in each table that held their data, e.g.
select count(*) from public.orders where user_id = 'DELETED-USER-ID';- every count should be 0, except tables you deliberately set toset null.
One limit to know: deleting the user cannot cancel an access token that was already issued. Supabase access tokens stay valid until they expire, so an app that was open during deletion can still make requests for a short time. Supabase suggests keeping the token expiry short and, for sensitive operations, checking the session against auth.sessions (User Management).
When you resubmit, use the Review Notes in App Store Connect to say where the deletion option is (for example: Settings > Account > Delete account) and include a demo account the reviewer can delete.
When to get help
- Users share data - teams, workspaces, shared documents, chats. Deciding what is deleted and what stays for the other users is a product and data model decision, and a wrong cascade can delete other people's data.
- The app sells subscriptions, uses Stripe or Sign in with Apple, and the deletion flow has to coordinate several services.
- You are in a regulated area (health, finance) or have to keep some records by law, and need deletion and retention to work together.
- The foreign key changes fail on existing data, or the app breaks after the cascade changes and you cannot trace why.
- A launch date depends on this resubmission and you cannot afford another review cycle.
Sources
Primary documentation this guide was checked against. Platforms change - if something here no longer matches, the source wins.
- App Store Review Guidelines (last updated 2026-10-16)Apple Developer
- 5.1.1(v) - Offering account deletion in your appApple Developer
- Managing accountsApple Human Interface Guidelines
- Revoke tokensSign in with Apple REST API
- User Management (deleting users)Supabase docs
- auth.admin.deleteUser()Supabase docs
- Securing Edge FunctionsSupabase docs
- Deploy Edge Functions to productionSupabase docs
- Delete ObjectsSupabase docs
- Storage ownershipSupabase docs
- auth.signOut()Supabase docs
- pg_constraintPostgreSQL docs
- Constraints (foreign keys)PostgreSQL docs
- Delete a customerStripe API reference
Frequently asked questions
- Is a "Deactivate account" button enough for Apple?
- No. Apple's guidance says offering only to temporarily deactivate or disable an account is insufficient. You can offer deactivation as an extra option, but people must be able to delete the whole account record with its personal data.
- Can I ask users to email support to delete their account?
- Not unless your app is in a highly regulated industry. Apple says other apps should not require a phone call, an email, a support chat or another support flow. Confirmation steps inside the app, such as entering a code sent to the account's email, are allowed.
- Does the deletion have to happen immediately?
- No. Apple accepts a manual process or one that takes a reasonable amount of time, as long as you tell the person how long it will take and confirm when it is done. It still has to be started from inside the app.
- Why can't I just delete the user from the app with supabase-js?
- Because
auth.admin.deleteUser()needs a secret or service_role key, and that key bypasses all Row Level Security. Supabase says it must only be used on a server. Put the deletion in an Edge Function that checks the signed-in user and deletes only that user. - deleteUser returns an error. What is blocking it?
- The two usual suspects are files the user still owns in Storage (Supabase refuses to delete such a user) and a foreign key to
auth.userswithouton delete cascadeorset null. Run the Storage query and the foreign key query from the checks above with that user's ID to see which one it is. - My users sign up on the website. Does the iOS app still need account deletion?
- Yes. Apple's guidance says the app must offer deletion even if account creation links out to the browser, and adds that sending people to the browser to sign in or register is itself a poor experience under Guideline 4.
Related guides
Fixed-price audit
Want someone to check the whole app, not just this?
A review of data security, production readiness and App Store readiness for apps built with AI tools. 900 USD, a ranked list of fixes within 5 business days.