Chore/update to next 15 (#30075)

* Update Next.js docs for v15

* More awaiting

* remove async for pages router

* fix for dashboard connection guide

---------

Co-authored-by: Charis Lam <26616127+charislam@users.noreply.github.com>
This commit is contained in:
Terry Sutton
2024-10-24 12:56:20 -02:30
committed by GitHub
parent 3a3360bbd0
commit bb0306061d
12 changed files with 32 additions and 29 deletions

View File

@@ -14,7 +14,7 @@ For a complete run-down on how all of our tools work together, see the main DEVE
## Local setup
[supabase.com/docs](https://supabase.com/docs) is a Next.JS site. You can get setup by following the same steps for all of our other Next.JS projects:
[supabase.com/docs](https://supabase.com/docs) is a Next.js site. You can get setup by following the same steps for all of our other Next.js projects:
1. Follow the steps outlined in the Local Development section of the main [DEVELOPERS.md](https://github.com/supabase/supabase/blob/master/DEVELOPERS.md)
2. If you work at Supabase, run `dev:secrets:pull` to pull down the internal environment variables. If you're a community member, create a `.env` file and add this line to it: `NEXT_PUBLIC_IS_PLATFORM=false`

View File

@@ -31,7 +31,7 @@ We use documentation specifications which can be used to generate human-readable
- CLISpec (custom to Supabase): for CLI commands and usage.
The benefit of using custom specifications is that we can generate many other types from a strict schema (eg, HTML and manpages).
It also means that we can switch to any documentation system we want. On this site we use Next.JS, but on Supabase's official website, we use a custom React site and expose only a subset of the available API for each tool.
It also means that we can switch to any documentation system we want. On this site we use Next.js, but on Supabase's official website, we use a custom React site and expose only a subset of the available API for each tool.
## Contributing

View File

@@ -68,7 +68,7 @@ export async function GET(request: Request) {
const next = searchParams.get('next') ?? '/'
if (code) {
const supabase = createClient()
const supabase = await createClient()
const { error } = await supabase.auth.exchangeCodeForSession(code)
if (!error) {
const forwardedHost = request.headers.get('x-forwarded-host') // original origin before load balancer

View File

@@ -20,7 +20,7 @@ The `auth-helpers` package has been replaced with the `@supabase/ssr` package. W
size="medium"
className="text-foreground-light border-b mt-8 pb-2"
>
<AccordionItem
header="See legacy docs"
id="legacy-docs"
@@ -218,7 +218,7 @@ export async function GET(request: NextRequest) {
const code = requestUrl.searchParams.get('code')
if (code) {
const cookieStore = cookies()
const cookieStore = await cookies()
const supabase = createRouteHandlerClient<Database>({ cookies: () => cookieStore })
await supabase.auth.exchangeCodeForSession(code)
}

View File

@@ -184,7 +184,7 @@ export async function GET(request: NextRequest) {
redirectTo.pathname = next
if (token_hash && type) {
const supabase = createClient()
const supabase = await createClient()
const { error } = await supabase.auth.verifyOtp({
type,
@@ -648,7 +648,7 @@ export async function GET(request: NextRequest) {
redirectTo.pathname = next
if (token_hash && type) {
const supabase = createClient()
const supabase = await createClient()
const { error } = await supabase.auth.verifyOtp({
type,

View File

@@ -72,9 +72,7 @@ hideToc: true
Start the development server, go to http://localhost:3000 in a browser, and you should see the contents of `app/page.tsx`.
To Sign Up a new user, navigate to http://localhost:3000/login, and click `Sign Up Now`.
Check out the [Supabase Auth docs](https://supabase.com/docs/guides/auth#authentication) for more authentication methods.
To sign up a new user, navigate to http://localhost:3000/login, and click `Sign Up Now`.
</StepHikeCompact.Details>
@@ -88,3 +86,8 @@ hideToc: true
</StepHikeCompact.Step>
</StepHikeCompact>
## Learn more
- [Setting up Server-Side Auth for Next.js](https://supabase.com/docs/guides/auth/server-side/nextjs) for a Next.js deep dive
- [Supabase Auth docs](https://supabase.com/docs/guides/auth#authentication) for more Supabase authentication methods

View File

@@ -171,8 +171,8 @@ export function createClient() {
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'
export function createClient() {
const cookieStore = cookies()
export async function createClient() {
const cookieStore = await cookies()
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,

View File

@@ -125,8 +125,8 @@ export function createClient() {
import { createServerClient, type CookieOptions } from '@supabase/ssr'
import { cookies } from 'next/headers'
export function createClient() {
const cookieStore = cookies()
export async function createClient() {
const cookieStore = await cookies()
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,
@@ -337,7 +337,7 @@ import { redirect } from 'next/navigation'
import { createClient } from '@/utils/supabase/server'
export async function login(formData: FormData) {
const supabase = createClient()
const supabase = await createClient()
// type-casting here for convenience
// in practice, you should validate your inputs
@@ -357,7 +357,7 @@ export async function login(formData: FormData) {
}
export async function signup(formData: FormData) {
const supabase = createClient()
const supabase = await createClient()
// type-casting here for convenience
// in practice, you should validate your inputs
@@ -429,7 +429,7 @@ export async function GET(request: NextRequest) {
const next = searchParams.get('next') ?? '/'
if (token_hash && type) {
const supabase = createClient()
const supabase = await createClient()
const { error } = await supabase.auth.verifyOtp({
type,
@@ -482,7 +482,7 @@ import { redirect } from 'next/navigation'
import { createClient } from '@/utils/supabase/server'
export default async function PrivatePage() {
const supabase = createClient()
const supabase = await createClient()
const { data, error } = await supabase.auth.getUser()
if (error || !data?.user) {

View File

@@ -341,9 +341,9 @@ Most web apps and websites can utilize Google's [personalized sign-in buttons](h
// Use 'nonce' when invoking the supabase.auth.signInWithIdToken() method
```
### One-tap with NextJS
### One-tap with Next.js
If you're integrating Google One-Tap with your NextJS application, you can refer to the example below to get started:
If you're integrating Google One-Tap with your Next.js application, you can refer to the example below to get started:
```tsx
'use client'

View File

@@ -8,7 +8,7 @@ hideToc: true
<StepHikeCompact>
<StepHikeCompact.Step step={1}>
<StepHikeCompact.Details title="Create a Supabase project">
Go to [database.new](https://database.new) and create a new Supabase project.
@@ -118,7 +118,7 @@ hideToc: true
import { createClient } from '@/utils/supabase/server';
export default async function Notes() {
const supabase = createClient();
const supabase = await createClient();
const { data: notes } = await supabase.from("notes").select();
return <pre>{JSON.stringify(notes, null, 2)}</pre>
@@ -129,8 +129,8 @@ hideToc: true
import { createServerClient } from '@supabase/ssr'
import { cookies } from 'next/headers'
export function createClient() {
const cookieStore = cookies()
export async function createClient() {
const cookieStore = await cookies()
return createServerClient(
process.env.NEXT_PUBLIC_SUPABASE_URL!,

View File

@@ -385,7 +385,7 @@ import { redirect } from 'next/navigation'
import { createClient } from '@/utils/supabase/server'
export async function login(formData) {
const supabase = createClient()
const supabase = await createClient()
// type-casting here for convenience
// in practice, you should validate your inputs
@@ -405,7 +405,7 @@ export async function login(formData) {
}
export async function signup(formData) {
const supabase = createClient()
const supabase = await createClient()
const data = {
email: formData.get('email'),
@@ -512,7 +512,7 @@ export async function GET(request) {
redirectTo.searchParams.delete('type')
if (token_hash && type) {
const supabase = createClient()
const supabase = await createClient()
const { error } = await supabase.auth.verifyOtp({
type,
@@ -720,7 +720,7 @@ import AccountForm from './account-form'
import { createClient } from '@/utils/supabase/server'
export default async function Account() {
const supabase = createClient()
const supabase = await createClient()
const {
data: { user },

View File

@@ -35,7 +35,7 @@ import { createClient } from '@/utils/supabase/server'
import { cookies } from 'next/headers'
export default async function Page() {
const cookieStore = cookies()
const cookieStore = await cookies()
const supabase = createClient(cookieStore)
const { data: todos } = await supabase.from('todos').select()