The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Update migration notes
dannykng12ce4f815e8b
diff --git a/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdx b/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdxindex 33c9458cb73..8a9c6595c0a 100644--- a/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdx+++ b/apps/reference/docs/guides/auth/auth-helpers/nextjs.mdx@@ -340,63 +340,55 @@ export const config = {}```-## Migrating to `0.4.X`--- With the update to `supabase-js` v2 the `auth` API routes are no longer required, therefore you can go ahead and delete your `auth` directory under the `/pages/api/` directory.--- The `/api/auth/logout` API route has been removed, please use the `signout` method instead:--```js-<button- onClick={async () => {- await supabaseClient.auth.signOut()- router.push('/')- }}->- Logout-</button>-```--- The `supabaseClient` and `supabaseServerClient` have been removed in favor of the `createBrowserSupabaseClient` and `createServerSupabaseClient` methods. This is so that you can provide the CLI generated types to the client, e.g.--```js-// client-side-import type { Database } from 'types_db';-const [supabaseClient] = useState(() =>- createBrowserSupabaseClient<Database>()- );--// server-side API route-import type { NextApiRequest, NextApiResponse } from 'next'-import type { Database } from 'types_db';--export default async (req: NextApiRequest, res: NextApiResponse) => {- const supabaseServerClient = createServerSupabaseClient<Database>({ req, res })- const { data:{ user } } = await supabaseServerClient.auth.getUser()-- res.status(200).json({ name: user?.name ?? '' })-}-```-+## Migrating to version `0.4.X` {#migration}++- With `supabase-js` v2, the `auth` API routes are no longer required and you can delete the `auth` directory under the `/pages/api/` directory.+- The `/api/auth/logout` API route has been removed—use the `signout` method instead.+ ```js+ <button+ onClick={async () => {+ await supabaseClient.auth.signOut()+ router.push('/')+ }}+ >+ Logout+ </button>+ ```+- The `supabaseClient` and `supabaseServerClient` have been removed in favor of the `createBrowserSupabaseClient` and `createServerSupabaseClient` methods. This allows you to provide the CLI-generated types to the client:+ ```js+ // client-side+ import type { Database } from 'types_db';+ const [supabaseClient] = useState(() =>+ createBrowserSupabaseClient<Database>()+ );++ // server-side API route+ import type { NextApiRequest, NextApiResponse } from 'next'+ import type { Database } from 'types_db';++ export default async (req: NextApiRequest, res: NextApiResponse) => {+ const supabaseServerClient = createServerSupabaseClient<Database>({ req, res })+ const { data:{ user } } = await supabaseServerClient.auth.getUser()++ res.status(200).json({ name: user?.name ?? '' })+ }+ ```- The `UserProvider` has been replaced by the `SessionContextProvider`. Make sure to wrap your `pages/_app.js` componenent with the `SessionContextProvider`. Then, throughout your application you can use the `useSessionContext` hook to get the `session` and the `useSupabaseClient` hook to get an authenticated `supabaseClient`.-- The `useUser` hook now returns the `user` object or `null`.-- Usage with TypeScript: You can pass types that were [generated with the Supabase CLI](https://supabase.com/docs/reference/javascript/next/typescript-support#generating-types) to the Supabase Client to get enhanced type safety and auto completion:--```js-// Creating a new supabase client object:-import { Database } from '../db_types';--const [supabaseClient] = useState(() =>- createBrowserSupabaseClient<Database>()- );-```--```js-// Retrieving a supabase client object from the SessionContext:-import { useSupabaseClient } from '@supabase/auth-helpers-react';-import { Database } from '../db_types';--const supabaseClient = useSupabaseClient<Database>();-```+ ```js+ // Creating a new supabase client object:+ import { Database } from '../db_types';++ const [supabaseClient] = useState(() =>+ createBrowserSupabaseClient<Database>()+ );+ ```++ ```js+ // Retrieving a supabase client object from the SessionContext:+ import { useSupabaseClient } from '@supabase/auth-helpers-react';+ import { Database } from '../db_types';++ const supabaseClient = useSupabaseClient<Database>();+ ```