© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
SupabaseS
Supabase•4y ago•
1 reply
felsey

Row level security and data insert with react native

Hi there,

I have a react native app and have auth setup, so that a session is created when a user logs in with their phone number.

I have row level security setup with the rule to allow users to do anything to their own lists.

But when testing if I try to create a list I'm getting this error:

error:  {"code": "42501", "details": null, "hint": null, "message": "new row violates row-level security policy for table \"lists\""}
error:  {"code": "42501", "details": null, "hint": null, "message": "new row violates row-level security policy for table \"lists\""}


This isn't making much sense to me because there is definitely a session for the user and I'm even passing in the user.id from the session into the user_id field in the table.

  const handleCreateList = async () => {
    try {
      setIsLoading(true);
      const { data, error } = await supabase
        .from("lists")
        .insert([
          {
            user_id: user.id,
            name: listName,
            google_place_id: selectedPlace.placeId,
            google_place_name: selectedPlace.description,
            google_place_types: JSON.stringify(selectedPlace.types),
          },
        ])
        .select();

      if (error) {
        throw error;
      }

      console.log(data[0].id);

      navigation.navigate("ListOverview", { listId: data[0].id });
    } catch (error) {
      console.log("error: ", error);
    } finally {
      setIsLoading(false);
    }
  };
  const handleCreateList = async () => {
    try {
      setIsLoading(true);
      const { data, error } = await supabase
        .from("lists")
        .insert([
          {
            user_id: user.id,
            name: listName,
            google_place_id: selectedPlace.placeId,
            google_place_name: selectedPlace.description,
            google_place_types: JSON.stringify(selectedPlace.types),
          },
        ])
        .select();

      if (error) {
        throw error;
      }

      console.log(data[0].id);

      navigation.navigate("ListOverview", { listId: data[0].id });
    } catch (error) {
      console.log("error: ", error);
    } finally {
      setIsLoading(false);
    }
  };


Any ideas what the issue could be?

I run into a similar row level security issue when trying to read data using
select
select
with a logged in user.
Screen_Shot_2022-09-17_at_2.25.28_AM.png
Supabase banner
SupabaseJoin
Supabase gives you the tools, documentation, and community that makes managing databases, authentication, and backend infrastructure a lot less overwhelming.
45,816Members
Resources
Was this page helpful?

Similar Threads

Recent Announcements

Similar Threads

row level security and react query
SupabaseSSupabase / help-and-questions
4y ago
Help with row level security
SupabaseSSupabase / help-and-questions
12mo ago
ROW LEVEL SECURITY ISSUE
SupabaseSSupabase / help-and-questions
3y ago
Row level security; data returns null with join query
SupabaseSSupabase / help-and-questions
4y ago