Environment variables
Create a file named.env.local in the root of the project. Next.js automatically loads this file during development and it is never sent to the browser unless a variable is prefixed with NEXT_PUBLIC_.
Variable reference
| Variable | Required | Description |
|---|---|---|
NEXT_PUBLIC_SUPABASE_URL | Yes | The base URL of your Supabase project’s REST and Auth API. |
NEXT_PUBLIC_SUPABASE_ANON_KEY | Yes | The public anonymous key used for unauthenticated and client-side Supabase requests. |
Both variables are prefixed with
NEXT_PUBLIC_ because the Supabase browser client (src/utils/supabase/client.js) reads them directly in client-side code. Without this prefix, Next.js would keep them server-side only and the client would fail to initialize.How to get your Supabase credentials
Log in to Supabase
Go to https://supabase.com and sign in to your account. If you don’t have one, create a free account.
Open your project
From the Supabase dashboard, select the project you want to connect to, or create a new one by clicking New project.
Navigate to project settings
In the left sidebar, click Project Settings, then select the Data API section (previously labeled API).
Copy the project URL and anon key
Under Project URL, copy the URL — this is your
NEXT_PUBLIC_SUPABASE_URL.Under Project API keys, copy the anon / public key — this is your NEXT_PUBLIC_SUPABASE_ANON_KEY.How the Supabase client uses these variables
The browser-side Supabase client is initialized insrc/utils/supabase/client.js:
Next.js configuration
Thenext.config.mjs file is intentionally minimal — no custom configuration is required:
Available npm scripts
The following scripts are defined inpackage.json:
| Script | Command | Description |
|---|---|---|
dev | npm run dev | Starts the development server at http://localhost:3000 with hot reloading. |
build | npm run build | Compiles the application for production. |
start | npm run start | Starts the production server after a build. Run npm run build first. |