From 8775bb8fbe7a11483bd8a7eb848302d79d6d5565 Mon Sep 17 00:00:00 2001 From: Danilo Herrera Date: Sun, 18 Dec 2022 13:09:51 -0500 Subject: [PATCH 1/2] docs: update server components doc --- .../auth/auth-helpers/nextjs-server-components.mdx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx b/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx index 346c8d7f3bc..815073394da 100644 --- a/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx +++ b/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx @@ -95,7 +95,7 @@ Create a new file at `/utils/supabase-browser.ts` and populate with the followin ```ts import { createBrowserSupabaseClient } from '@supabase/auth-helpers-nextjs' -import { Database } from '../db_types' +import { Database } from '../lib/database.types' export default createBrowserSupabaseClient() ``` @@ -109,7 +109,7 @@ Create a new file at `/utils/supabase-server.ts` and populate with the following ```ts title="/utils/supabase-server.ts" import { headers, cookies } from 'next/headers' import { createServerComponentSupabaseClient } from '@supabase/auth-helpers-nextjs' -import { Database } from '../db_types' +import { Database } from '../lib/database.types' export default () => createServerComponentSupabaseClient({ @@ -139,6 +139,8 @@ Middleware runs before every route declared in the `matcher` array. Since we don > +Create a new file at `/pages/middleware.js` and populate with the following: + ```jsx title="middleware.js" import { createMiddlewareSupabaseClient } from '@supabase/auth-helpers-nextjs' import { NextResponse } from 'next/server' @@ -164,6 +166,8 @@ export const config = { +Create a new file at `/pages/middleware.ts` and populate with the following: + ```tsx title="middleware.ts" import { createMiddlewareSupabaseClient } from '@supabase/auth-helpers-nextjs' import { NextResponse } from 'next/server' @@ -254,7 +258,7 @@ export default async function RootLayout({ children }) { } ``` -We don't want Next.js to cache this `session` value, so we need to export a `revalidate` value of `0`. +We don't want Next.js to cache this `session` value, so we need to export a `revalidate` value of `0` in the layout file. ```jsx export const revalidate = 0 @@ -641,7 +645,7 @@ Create a new file at `/app/realtime/posts.tsx` and populate with the following: 'use client' import { useEffect, useState } from 'react' -import { Database } from '../../db_types' +import { Database } from '../lib/database.types' import supabase from '../../utils/supabase-browser' type Post = Database['public']['Tables']['posts']['Row'] From 0dcb4910599f09116ea21335f8ced77c3d4382c0 Mon Sep 17 00:00:00 2001 From: Terry Sutton Date: Mon, 19 Dec 2022 11:50:42 -0330 Subject: [PATCH 2/2] Update apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx --- .../pages/guides/auth/auth-helpers/nextjs-server-components.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx b/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx index 815073394da..10fa7f73f31 100644 --- a/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx +++ b/apps/docs/pages/guides/auth/auth-helpers/nextjs-server-components.mdx @@ -166,7 +166,7 @@ export const config = { -Create a new file at `/pages/middleware.ts` and populate with the following: +Create a new file at `/middleware.ts` (a sibling of /pages) and populate with the following: ```tsx title="middleware.ts" import { createMiddlewareSupabaseClient } from '@supabase/auth-helpers-nextjs'