The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Prettier/formatting
dngcea59aecffb3
diff --git a/apps/reference/_auth_helpers/next-js.md b/apps/reference/_auth_helpers/next-js.mdindex 22152f1a51b..e5306de5ccd 100644--- a/apps/reference/_auth_helpers/next-js.md+++ b/apps/reference/_auth_helpers/next-js.md@@ -281,34 +281,32 @@ If you visit `/api/protected-route` without a valid session cookie, you will getAs an alternative to protecting individual pages using `getServerSideProps` with `withPageAuth`, `withMiddlewareAuth` can be used from inside a `middleware` file to protect the entire directory or those that match the config object. In the following example, all requests to `/middleware-protected/*` will check whether a user is signed in, if successful the request will be forwarded to the destination route, otherwise the user will be redirected to `/login` (defaults to: `/`) with a 307 Temporary Redirect response status:-```ts-// /middleware.ts-import { withMiddlewareAuth } from '@supabase/auth-helpers-nextjs';+```ts title="/middleware.ts"+import { withMiddlewareAuth } from '@supabase/auth-helpers-nextjs'-export const middleware = withMiddlewareAuth({ redirectTo: '/' });+export const middleware = withMiddlewareAuth({ redirectTo: '/' })export const config = {- matcher: ['/middleware-protected/:path*']-};+ matcher: ['/middleware-protected/:path*'],+}```It is also possible to add finer granularity based on the user logged in. I.e. you can specify a promise to determine if a specific user has permission or not.-```ts-// middlware.ts-import { withMiddlewareAuth } from '@supabase/auth-helpers-nextjs/middleware';+```ts title="/middleware.ts"+import { withMiddlewareAuth } from '@supabase/auth-helpers-nextjs/middleware'export const middleware = withMiddlewareAuth({redirectTo: '/login',authGuard: {isPermitted: async (user) => user.email?.endsWith('@example.com') ?? false,- redirectTo: '/insufficient-permissions'- }-});+ redirectTo: '/insufficient-permissions',+ },+})export const config = {- matcher: ['/middleware-protected/:path*']-};+ matcher: ['/middleware-protected/:path*'],+}```## Migrating from @supabase/supabase-auth-helpers to @supabase/auth-helpers