Next.js 13/14 stale data when changing RLS or table data.
Last edited: 1/17/2025
Next.js caches urls in certain cases. This is causing users to lose lots of time debugging early on with RLS changes. Changing the table data in the UI will also not be returned in these cases.
You can look at the Dashboard API Edge log to see if the request is making it to Supabase.
Another way to check if the url caching is impacting you is to change .select('*')
to .select('colname')
or change column names. This would bust the next.js cache.
Users have suggested the following three options to turn off the caching, but please refer to next.js docs as needed.
export const dynamic = 'force-dynamic'; // no caching
or
export const fetchCache = 'force-no-store' // to page.js
or
export const revalidate = 0