Skip to content

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

docs: add Automatic Configuration section to Next.js Auth Helpers docs

Jon Meyersc85fbf118c8d
diff --git a/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx b/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
index f1cd26dba4a..99ceaa1f86b 100644
--- a/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
+++ b/apps/docs/pages/guides/auth/auth-helpers/nextjs.mdx
@@ -25,7 +25,40 @@ If you are using the `pages` directory, check out [Auth Helpers in Next.js Pages
</Admonition>
-## Configuration
+## Automatic Configuration (recommended)
+
+Use the `create-next-app` command and the `with-supabase` template to automate the configuration of cookie-based auth with the Next.js Auth Helpers.
+
+```sh
+npx create-next-app -e with-supabase
+```
+
+This creates a new Next.js app configured with:
+
+- [Cookie-based Auth](/docs/guides/auth/auth-helpers/nextjs#authentication)
+- [Middleware to refresh user's session](/docs/guides/auth/auth-helpers/nextjs#managing-session-with-middleware)
+- [Code Exchange Route](/docs/guides/auth/auth-helpers/nextjs#Managing-sign-in-with-code-exchange)
+- [TypeScript](https://www.typescriptlang.org/)
+- [Tailwind CSS](https://tailwindcss.com/)
+
+### Declare Environment Variables
+
+Retrieve your project's URL and anon key from your [API settings](https://app.supabase.com/project/_/settings/api), and create a `.env.local` file with the following environment variables:
+
+```bash .env.local
+NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
+NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
+```
+
+### Run Next.js App
+
+Run the development server and navigate to http://localhost:3000.
+
+```bash
+npm run dev
+```
+
+## Manual Configuration
### Install Next.js Auth Helpers library
@@ -61,8 +94,6 @@ NEXT_PUBLIC_SUPABASE_URL=your-supabase-url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your-supabase-anon-key
```
-Make sure you name these variables exactly as seen here, since these are picked up by the auth helpers library — you no longer have to explicitly pass them to a `createClient()` function as before.
-
### Managing session with Middleware
When using the Supabase client on the server, you must perform extra steps to ensure the user's auth session remains active. Since the user's session is tracked in a cookie, we need to read this cookie and update it if necessary.