Unverified Commit 76ebbb97 authored by Karthikeya Thatipamula's avatar Karthikeya Thatipamula Committed by GitHub

docs: add missing RLS step to Next.js tutorial (#82714)

## What
This PR updates
`examples/with-supabase/components/tutorial/fetch-data-steps.tsx` to
include a missing step about enabling Row Level Security (RLS) and
creating a simple read policy for the `notes` table.

Fixes: #82218

## Why
Currently, the tutorial shows how to:
- create a `notes` table
- insert data
- query data from Next.js

However, since RLS is enabled by default in Supabase, new users will get
`permission denied` errors when querying data unless they configure
policies.
The official Supabase Next.js quickstart docs already mention this:  
https://supabase.com/docs/guides/getting-started/quickstarts/nextjs

Adding this step will help newcomers understand why RLS is required and
how to set it up.

## Changes
- Added a new `<TutorialStep>` in `fetch-data-steps.tsx`:
  - Explains that RLS is enabled by default
  - Shows SQL snippet to enable RLS + create a public read policy
  - Links to the Supabase RLS docs

## Checklist
- [x] Added RLS tutorial step
- [x] Verified formatting matches other tutorial steps
- [x] Added links to relevant Supabase docs
Co-authored-by: 's avatarJoseph <joseph.chamochumbi@vercel.com>
parent ae9261fb
...@@ -13,6 +13,11 @@ values ...@@ -13,6 +13,11 @@ values
('It was awesome!'); ('It was awesome!');
`.trim(); `.trim();
const rls = `alter table notes enable row level security;
create policy "Allow public read access" on notes
for select
using (true);`.trim();
const server = `import { createClient } from '@/utils/supabase/server' const server = `import { createClient } from '@/utils/supabase/server'
export default async function Page() { export default async function Page() {
...@@ -74,6 +79,49 @@ export function FetchDataSteps() { ...@@ -74,6 +79,49 @@ export function FetchDataSteps() {
<CodeBlock code={create} /> <CodeBlock code={create} />
</TutorialStep> </TutorialStep>
<TutorialStep title="Enable Row Level Security (RLS)">
<p>
Supabase enables Row Level Security (RLS) by default. To query data
from your <code>notes</code> table, you need to add a policy. You can
do this in the{" "}
<a
href="https://supabase.com/dashboard/project/_/editor"
className="font-bold hover:underline text-foreground/80"
target="_blank"
rel="noreferrer"
>
Table Editor
</a>{" "}
or via the{" "}
<a
href="https://supabase.com/dashboard/project/_/sql/new"
className="font-bold hover:underline text-foreground/80"
target="_blank"
rel="noreferrer"
>
SQL Editor
</a>
.
</p>
<p>
For example, you can run the following SQL to allow public read
access:
</p>
<CodeBlock code={rls} />
<p>
You can learn more about RLS in the{" "}
<a
href="https://supabase.com/docs/guides/auth/row-level-security"
className="font-bold hover:underline text-foreground/80"
target="_blank"
rel="noreferrer"
>
Supabase docs
</a>
.
</p>
</TutorialStep>
<TutorialStep title="Query Supabase data from Next.js"> <TutorialStep title="Query Supabase data from Next.js">
<p> <p>
To create a Supabase client and query data from an Async Server To create a Supabase client and query data from an Async Server
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment