Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs: Improve the steps for NextJS quickstart (#37929)

Chris Chinchilla7f50ee9dd280
diff --git a/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx b/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx
index a6633706faa..14690e27cc3 100644
--- a/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx
+++ b/apps/docs/content/guides/getting-started/quickstarts/nextjs.mdx
@@ -59,12 +59,12 @@ hideToc: true
</StepHikeCompact.Step>
- <StepHikeCompact.Step step={4}>
- <StepHikeCompact.Details title="Query Supabase data from Next.js">
+<StepHikeCompact.Step step={4}>
+ <StepHikeCompact.Details title="Create Supabase client">
- Create a new file at `app/instruments/page.tsx` and populate with the following.
+ Create a new file at `utils/supabase/server.ts` and populate with the following.
- This will select all the rows from the `instruments` table in Supabase and render them on the page.
+ This creates a Supabase client, using the credentials from the `env.local` file.
</StepHikeCompact.Details>
@@ -72,17 +72,6 @@ hideToc: true
<$CodeTabs>
- ```ts name=app/instruments/page.tsx
- import { createClient } from '@/utils/supabase/server';
-
- export default async function Instruments() {
- const supabase = await createClient();
- const { data: instruments } = await supabase.from("instruments").select();
-
- return <pre>{JSON.stringify(instruments, null, 2)}</pre>
- }
- ```
-
```ts name=utils/supabase/server.ts
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'
@@ -122,6 +111,36 @@ hideToc: true
</StepHikeCompact.Step>
<StepHikeCompact.Step step={5}>
+ <StepHikeCompact.Details title="Query Supabase data from Next.js">
+
+ Create a new file at `app/instruments/page.tsx` and populate with the following.
+
+ This selects all the rows from the `instruments` table in Supabase and render them on the page.
+
+ </StepHikeCompact.Details>
+
+ <StepHikeCompact.Code>
+
+ <$CodeTabs>
+
+ ```ts name=app/instruments/page.tsx
+ import { createClient } from '@/utils/supabase/server';
+
+ export default async function Instruments() {
+ const supabase = await createClient();
+ const { data: instruments } = await supabase.from("instruments").select();
+
+ return <pre>{JSON.stringify(instruments, null, 2)}</pre>
+ }
+ ```
+
+ </$CodeTabs>
+
+ </StepHikeCompact.Code>
+
+ </StepHikeCompact.Step>
+
+ <StepHikeCompact.Step step={6}>
<StepHikeCompact.Details title="Start the app">
Run the development server, go to http://localhost:3000/instruments in a browser and you should see the list of instruments.