The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
chore: update nextjs-todo-list guide and config.toml (#30716)
Andrew Valleteaud2657975413d
diff --git a/examples/todo-list/nextjs-todo-list/.env.example b/examples/todo-list/nextjs-todo-list/.env.examplenew file mode 100644index 00000000000..ea091e9b1d5--- /dev/null+++ b/examples/todo-list/nextjs-todo-list/.env.example@@ -0,0 +1,5 @@+# Update these with your Supabase details from your project settings > API+NEXT_PUBLIC_SUPABASE_URL=http://127.0.0.1:54321+NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0+NEXT_SITE_URL=http://localhost:3000+NEXT_REDIRECT_URLS=http://localhost:3000/diff --git a/examples/todo-list/nextjs-todo-list/.env.local.example b/examples/todo-list/nextjs-todo-list/.env.local.exampledeleted file mode 100644index 477da3d401d..00000000000--- a/examples/todo-list/nextjs-todo-list/.env.local.example+++ /dev/null@@ -1,3 +0,0 @@-# Update these with your Supabase details from your project settings > API-NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co-NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key\ No newline at end of filediff --git a/examples/todo-list/nextjs-todo-list/.env.production.example b/examples/todo-list/nextjs-todo-list/.env.production.examplenew file mode 100644index 00000000000..05667daec5a--- /dev/null+++ b/examples/todo-list/nextjs-todo-list/.env.production.example@@ -0,0 +1,6 @@+# Get these from your API settings: https://supabase.com/dashboard/project/_/settings/api+NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co+NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-key+# Get this from your Vercel project settings+NEXT_SITE_URL=https://<your-vercel-project>.<your-vercel-org-name>.vercel.app/+NEXT_REDIRECT_URLS=https://<your-vercel-project>*.vercel.app/,https://<your-vercel-project>*.vercel.app/**diff --git a/examples/todo-list/nextjs-todo-list/README.md b/examples/todo-list/nextjs-todo-list/README.mdindex 2b04f4ffeae..2535f8d9e22 100644--- a/examples/todo-list/nextjs-todo-list/README.md+++ b/examples/todo-list/nextjs-todo-list/README.md@@ -13,8 +13,6 @@ The Vercel deployment will guide you through creating a Supabase account and pro[](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fsupabase%2Fsupabase%2Ftree%2Fmaster%2Fexamples%2Ftodo-list%2Fnextjs-todo-list&project-name=supabase-nextjs-todo-list&repository-name=supabase-nextjs-todo-list&integration-ids=oac_VqOgBHqhEoFTPzGkPd7L0iH6&external-id=https%3A%2F%2Fgithub.com%2Fsupabase%2Fsupabase%2Ftree%2Fmaster%2Fexamples%2Ftodo-list%2Fnextjs-todo-list)-## Build from scratch-### 1. Create new projectSign up to Supabase - [https://supabase.com/dashboard](https://supabase.com/dashboard) and create a new project. Wait for your database to start.@@ -35,6 +33,48 @@ The `anon` key is your client-side API key. It allows "anonymous access" to your## Supabase details+### Using a Remote Supabase Project++1. Create or select a project on [Supabase Dashboard](https://supabase.com/dashboard).+2. Copy and fill the dotenv template `cp .env.production.example .env.production`+3. Link the local project and merge the local configuration with the remote one:++```bash+SUPABASE_ENV=production npx supabase@latest link --project-ref <your-project-ref>+```++3. Sync the configuration:++```bash+SUPABASE_ENV=production npx supabase@latest config push+```++4. Sync the database schema:++```bash+SUPABASE_ENV=production npx supabase@latest db push+```++## Vercel Preview with Branching++Supabase integrates seamlessly with Vercel's preview branches, giving each branch a dedicated Supabase project. This setup allows testing database migrations or service configurations safely before applying them to production.++### Steps++1. Ensure the Vercel project is linked to a Git repository.+2. Configure the "Preview" environment variables in Vercel:++ - `NEXT_PUBLIC_SUPABASE_URL`+ - `NEXT_PUBLIC_SUPABASE_ANON_KEY`++3. Create a new branch, make changes (e.g., update `max_frequency`), and push the branch to Git.+ - Open a pull request to trigger Vercel + Supabase integration.+ - Upon successful deployment, the preview environment reflects the changes.++++---+### Postgres Row level securityThis project uses very high-level Authorization using Postgres' Row Level Security.diff --git a/examples/todo-list/nextjs-todo-list/supabase/.gitignore b/examples/todo-list/nextjs-todo-list/supabase/.gitignoreindex 773c7c3e0a1..a3ad88055b7 100644--- a/examples/todo-list/nextjs-todo-list/supabase/.gitignore+++ b/examples/todo-list/nextjs-todo-list/supabase/.gitignore@@ -1,3 +1,4 @@# Supabase.branches.temp+.envdiff --git a/examples/todo-list/nextjs-todo-list/supabase/config.toml b/examples/todo-list/nextjs-todo-list/supabase/config.tomlindex e3274f86e33..60860aa0ffe 100644--- a/examples/todo-list/nextjs-todo-list/supabase/config.toml+++ b/examples/todo-list/nextjs-todo-list/supabase/config.toml@@ -1,14 +1,15 @@-# A string used to distinguish different Supabase projects on the same host. Defaults to the working-# directory name when running `supabase init`.+# A string used to distinguish different Supabase projects on the same host. Defaults to the+# working directory name when running `supabase init`.project_id = "nextjs-todo-list"[api]+enabled = true# Port to use for the API URL.port = 54321# Schemas to expose in your API. Tables, views and stored procedures in this schema will get API-# endpoints. public and storage are always included.-schemas = ["public", "storage", "graphql_public"]-# Extra schemas to add to the search_path of every request. public is always included.+# endpoints. `public` and `graphql_public` are included by default.+schemas = ["public", "graphql_public"]+# Extra schemas to add to the search_path of every request.extra_search_path = ["public", "extensions"]# The maximum number of rows returns from a view, table, or stored procedure. Limits payload size# for accidental or malicious requests.@@ -17,37 +18,39 @@ max_rows = 1000[db]# Port to use for the local database URL.port = 54322+# Port used by db diff command to initialize the shadow database.+shadow_port = 54320# The database major version to use. This has to be the same as your remote database's. Run `SHOW# server_version;` on the remote database to check.major_version = 15-[studio]-# Port to use for Supabase Studio.-port = 54323--# Email testing server. Emails sent with the local dev setup are not actually sent - rather, they-# are monitored, and you can view the emails that would have been sent from the web interface.-[inbucket]-# Port to use for the email testing server web interface.-port = 54324-smtp_port = 54325-pop3_port = 54326--[storage]-# The maximum file size allowed (e.g. "5MB", "500KB").-file_size_limit = "50MiB"+[db.seed]+# If enabled, seeds the database after migrations during a db reset.+enabled = false+# Specifies an ordered list of seed files to load during db reset.+# Supports glob patterns relative to supabase directory. For example:+# sql_paths = ['./seeds/*.sql', '../project-src/seeds/*-load-testing.sql'][auth]+enabled = true# The base URL of your website. Used as an allow-list for redirects and for constructing URLs used# in emails.-site_url = "http://localhost:3000"+site_url = "env(NEXT_SITE_URL)"# A list of *exact* URLs that auth providers are permitted to redirect to post authentication.-additional_redirect_urls = ["https://localhost:3000"]-# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 seconds (one-# week).+additional_redirect_urls = ["env(NEXT_REDIRECT_URLS)"]+# How long tokens are valid for, in seconds. Defaults to 3600 (1 hour), maximum 604,800 (1 week).jwt_expiry = 3600+# If disabled, the refresh token will never expire.+enable_refresh_token_rotation = true+# Allows refresh tokens to be reused after expiry, up to the specified interval in seconds.+# Requires enable_refresh_token_rotation = true.+refresh_token_reuse_interval = 10# Allow/disallow new user signups to your project.enable_signup = true+# Allow/disallow anonymous sign-ins to your project.+enable_anonymous_sign_ins = false+# Allow/disallow testing manual linking of accounts+enable_manual_linking = false[auth.email]# Allow/disallow new user signups via email to your project.@@ -56,27 +59,12 @@ enable_signup = true# addresses. If disabled, only the new email is required to confirm.double_confirm_changes = true# If enabled, users need to confirm their email address before signing in.-enable_confirmations = false--# Use an external OAuth provider. The full list of providers are: `apple`, `azure`, `bitbucket`,-# `discord`, `facebook`, `github`, `gitlab`, `google`, `keycloak`, `linkedin`, `notion`, `twitch`,-# `twitter`, `slack`, `spotify`, `workos`, `zoom`.-[auth.external.apple]-enabled = false-client_id = ""-secret = ""-# Overrides the default auth redirectUrl.-redirect_uri = ""-# Overrides the default auth provider URL. Used to support self-hosted gitlab, single-tenant Azure,-# or any other third-party OIDC providers.-url = ""--[analytics]-enabled = false-port = 54327-vector_port = 54328-# Setup BigQuery project to enable log viewer on local development stack.-# See: https://supabase.com/docs/guides/getting-started/local-development#enabling-local-logging-gcp_project_id = ""-gcp_project_number = ""-gcp_jwt_path = "supabase/gcloud.json"+enable_confirmations = true+# If enabled, users will need to reauthenticate or have logged in recently to change their password.+secure_password_change = false+# Controls the minimum amount of time that must pass before sending another signup confirmation or password reset email.+max_frequency = "1m0s"+# Number of characters used in the email OTP.+otp_length = 6+# Number of seconds before the email OTP expires (defaults to 1 hour).+otp_expiry = 3600diff --git a/examples/todo-list/nextjs-todo-list/supabase/seed.sql b/examples/todo-list/nextjs-todo-list/supabase/seed.sqldeleted file mode 100644index e69de29bb2d..00000000000