Skip to content

Org and Project Creation

Author
Michael
Created
22 Nov 2026
Updated
22 Nov 2026
Tags
#supabase#cli#security#rls#migrations
Tip

In short: create an organization, create a project in a region close to your users, and save the database password straight away. Copy the project URL and the new publishable and secret keys into environment variables. Change the database with npx supabase db push --remote, or with the SQL editor, and turn on every hardening step in Security before the app goes anywhere public.

Overview

What: this guide creates the Supabase home for an app: an organization (the account that owns billing and members) and a project (the database, the API, and sign-in). It then puts the project URL and API keys into environment variables, and shows two ways to change the database:

Way When to use it
CLI migrations The schema lives in git. Use this once more than one person changes the database.
SQL editor You are exploring, or the change is a one-off. If the repo also uses migrations, pull that change into a migration afterwards.

Sign-in methods (email, Google, Microsoft, Resend) are a different page. Follow Sign In / Providers after the project exists.

Why: the project URL and keys are how the app talks to Supabase. The database password is how the CLI talks to Postgres. If those land in git, or a table is created without row level security, anyone with the publishable key can read the table.

Who it’s for: developers creating their first Supabase project, or adding the CLI to a project that already exists. You don’t need to have used the CLI before.

Prerequisites

What Details
Supabase account Sign up at supabase.com. Signing in with GitHub is fine.
Organization role Owner to create the organization and the project, and to invite people. A later project only needs Owner or Administrator.
A password manager The database password is shown once. Configure for Code is the 1Password way to store it and the API keys.
Node.js 20 or newer Only for the CLI path (Step 4). Check with node --version.
Docker Only if you want a database on your own machine (npx supabase start). Pushing to the hosted project does not need it.
Note

About the code: the examples are JavaScript and use @supabase/supabase-js. The environment variable names in Step 3 are the Next.js ones (NEXT_PUBLIC_... for anything the browser may see). Vite uses VITE_... for those same browser values. The secret key has no public prefix in either framework.

Architecture

The browser talks to Supabase with the publishable key. Your server, if you have one, talks to Supabase with the secret key. Postgres applies row level security to the publishable key. The secret key skips those rules.

flowchart LR
    classDef user fill:#CBD5E1,stroke:#475569,color:#060913
    classDef app fill:#38BDF8,stroke:#0284C7,color:#000810
    classDef cloud fill:#0B1121,stroke:#38BDF8,color:#E2E8F0
    classDef data fill:#075985,stroke:#38BDF8,color:#F8FAFC
    classDef secret fill:#F59E0B,stroke:#B45309,color:#1C1917

    U([Person]):::user -->|uses the app| A[Your app]:::app
    A -->|URL + publishable key| API[Supabase API]:::cloud
    API -->|query, row rules on| DB[(Postgres)]:::data
    S[Your server]:::app -->|URL + secret key| API
    K{{Keys + DB password}}:::secret -.->|copied into env| A
    K -.->|copied into env| S

Figure 1: The publishable key stays in the app. The secret key stays on the server. Both come from the project, and the database password stays in your password manager.

Settings are split across the organization, the project, and the repo.

flowchart TB
    classDef user fill:#CBD5E1,stroke:#475569,color:#060913
    classDef app fill:#38BDF8,stroke:#0284C7,color:#000810
    classDef cloud fill:#0B1121,stroke:#38BDF8,color:#E2E8F0
    classDef data fill:#075985,stroke:#38BDF8,color:#F8FAFC
    classDef secret fill:#F59E0B,stroke:#B45309,color:#1C1917
    classDef zone fill:transparent,stroke:#94A3B8,stroke-dasharray:4 3

    subgraph Org["Supabase organization"]
        direction LR
        U([You]):::user
        Team[Team and owners]:::cloud
    end
    subgraph Proj["Supabase project"]
        direction LR
        Keys{{API keys}}:::secret
        DB[(Postgres)]:::data
        Auth[Sign-in settings]:::cloud
    end
    subgraph Repo["Your repo"]
        direction LR
        App[Your app]:::app
        Mig[supabase/migrations]:::app
    end

    U -->|creates and invites| Team
    Team -->|owns| Proj
    Keys -.->|URL and keys| App
    Mig -->|db push --remote| DB
    Auth -->|who may sign in| DB
    class Org,Proj,Repo zone

Figure 2: The organization owns the project. Keys are copied into the app. Migrations in git are what the CLI applies to Postgres.

Pushing with the CLI is a preview, then a confirmed apply. The hosted database records which files have already run.

%%{init: {"theme": "base", "themeVariables": {"actorBkg": "#0B1121", "actorBorder": "#38BDF8", "actorTextColor": "#E2E8F0", "actorLineColor": "#718096", "signalColor": "#718096", "signalTextColor": "#718096", "textColor": "#718096", "loopTextColor": "#718096", "labelBoxBkgColor": "#38BDF8", "labelBoxBorderColor": "#0284C7", "labelTextColor": "#000810", "sequenceNumberColor": "#FFFFFF", "noteBkgColor": "#F59E0B", "noteBorderColor": "#B45309", "noteTextColor": "#1C1917"}}}%%
sequenceDiagram
    autonumber
    box rgba(148,163,184,0.15) Person
    participant U as You
    end
    box rgba(56,189,248,0.15) Your app
    participant CLI as Supabase CLI
    end
    box rgba(148,163,184,0.06) Services you use
    participant DB as Hosted Postgres
    end

    U->>CLI: migration new, then the SQL file
    U->>CLI: db push --dry-run --remote
    CLI->>DB: Which migrations are new?
    DB-->>CLI: The pending list
    U->>CLI: db push --remote, then confirm
    CLI->>DB: Runs the new SQL
    DB-->>CLI: Records them in schema_migrations

Figure 3: A dry run lists the pending files. The real push runs them and records them, so the next push skips them.

Step 1: Create the organization

  1. Open supabase.com/dashboard and sign in.
  2. Open the organization name at the top of the left sidebar.
  3. Choose New organization.
  4. Type a name. The short name in the URL (the slug) may only use letters, numbers, and hyphens.
  5. Pick a plan. The Free plan is enough to finish this guide. Enforcing multi-factor authentication for every member needs a paid plan, which Security covers.
  6. Create the organization.

You should now see the organization home, with no projects yet, or with a prompt to create one.

Skip this step if you already belong to the organization you want. You need the Owner role to create a project there.

Step 2: Create the project

  1. Open supabase.com/dashboard/new, or choose New project inside the organization.
  2. Select the organization from Step 1.
  3. In Name, type a name you’ll recognise in a list, such as the app’s name.
  4. Generate a database password. Copy it into your password manager before you leave the page. Supabase shows this password once. Configure for Code covers storing it in 1Password.
  5. Pick a region close to the people who use the app. The region stays put for the life of the project. A different region means a new project.
  6. Create the project, and wait until the dashboard says it is healthy. This usually takes a minute or two.

The project ref is the 20-letter id in the address bar:

https://supabase.com/dashboard/project/<your-project-ref>

The API host is https://<your-project-ref>.supabase.co. You’ll paste both in the next step.

Warning

Closing the page without saving the database password means you can’t connect the CLI later. Reset it from the Connect dialog, or from Project Settings → Database, and save the new one. Resetting it drops every existing database connection.

Step 3: Add the URL and keys

Supabase has two current keys. The publishable key is safe to ship in a browser. Row level security still applies to it. The secret key is for servers only. It uses the service_role database role and skips row level security.

Older projects also show anon and service_role keys that start with eyJ. Those are the legacy keys, and they stop being the ones to use at the end of 2026. If you only see those, choose Create new API keys on the same page.

  1. On the project home, open Connect. The same values are under Project Settings → API Keys. There is no separate Settings → API page.

  2. Copy the project URL.

  3. Copy the publishable key. It starts with sb_publishable_.

  4. Copy the secret key. It starts with sb_secret_. Put it in the password manager next to the database password.

  5. In the app repo, create a .env file that git ignores. Next.js names look like this (the angle brackets are placeholders, not real keys):

    Terminal window
    NEXT_PUBLIC_SUPABASE_URL=https://<your-project-ref>.supabase.co
    NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=<your-publishable-key>
    SUPABASE_URL=https://<your-project-ref>.supabase.co
    SUPABASE_SECRET_KEY=<your-secret-key>
  6. Make sure git will never commit that file. From the repo root:

    Terminal window
    printf '%s\n' '.env' '.env.local' '.env.*.local' 'supabase/.temp/' >> .gitignore
  7. Commit a template with empty values, so teammates know the names without seeing the secrets:

    Terminal window
    NEXT_PUBLIC_SUPABASE_URL=
    NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=
    SUPABASE_URL=
    SUPABASE_SECRET_KEY=

    Save that as .env.example.

Where the code runs URL Key
Browser, Next.js NEXT_PUBLIC_SUPABASE_URL NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY
Browser, Vite VITE_SUPABASE_URL VITE_SUPABASE_PUBLISHABLE_KEY
Server (any framework) SUPABASE_URL SUPABASE_SECRET_KEY

A browser client, using the Next.js names:

import { createClient } from '@supabase/supabase-js'
export const supabase = createClient(
process.env.NEXT_PUBLIC_SUPABASE_URL,
process.env.NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY,
)

A server client. Keep this file out of any browser bundle:

import { createClient } from '@supabase/supabase-js'
export const supabaseAdmin = createClient(
process.env.SUPABASE_URL,
process.env.SUPABASE_SECRET_KEY,
)
Caution

Security: a NEXT_PUBLIC_ or VITE_ prefix ships that variable to the browser. The secret key must not have one. Anyone who can read the secret key can read and write every row, whether or not row level security is on.

Edge Functions are the exception to those names. They read SUPABASE_PUBLISHABLE_KEYS and SUPABASE_SECRET_KEYS as JSON objects keyed by name (the usual name is default), not as a single string.

The database host is a separate copy-paste. Open Connect, choose the Session pooler (or the direct host), and copy that string. Don’t invent a hostname. The direct host is IPv6 unless the project has the IPv4 add-on. On an IPv4-only network, use the session pooler. Use the direct host (db.<your-project-ref>.supabase.co, port 5432) when the CLI pulls a schema, if your network can reach it. Don’t use the transaction pooler for db pull.

Step 4: Push database changes with the CLI

Install the CLI into the app so everyone gets the same version. In a Node project, run it with npx. A global install (brew, Scoop, or the Linux package) is the same commands without npx.

Every install channel now installs CLI v3. Database commands target a local database by default. --remote is what sends them to the hosted project.

  1. From the app root:

    Terminal window
    npm install supabase --save-dev
    npx supabase --version
  2. Sign the CLI in. A browser opens and creates an access token, which the CLI stores on this machine:

    Terminal window
    npx supabase login
  3. Create the local project folder:

    Terminal window
    npx supabase init

    This adds supabase/config.toml and supabase/migrations/. Commit both. config.toml has no secrets in a fresh project. supabase/.temp/ is CLI state: leave it gitignored (Step 3). If you later put a key in config.toml, reference an environment variable with env() instead of pasting the key.

  4. Point the folder at the hosted project. The CLI asks for the database password from Step 2. Type it, or export SUPABASE_DB_PASSWORD in the shell for this command. Don’t put the password in the command itself: it stays in shell history.

    Terminal window
    npx supabase link --project-ref <your-project-ref>
  5. Start a migration. The name is anything you’ll recognise later:

    Terminal window
    npx supabase migration new create_notes

    You get an empty file at supabase/migrations/<timestamp>_create_notes.sql. Put the table, the row level security switch, the grants, and the policies in that one file so the table is never public, even for a moment:

    create table public.notes (
    id bigint generated always as identity primary key,
    user_id uuid not null references auth.users (id) on delete cascade,
    body text not null,
    created_at timestamptz not null default now()
    );
    alter table public.notes enable row level security;
    revoke all on table public.notes from anon, authenticated;
    grant select, insert, update, delete on table public.notes to authenticated;
    create policy "Read own notes"
    on public.notes
    for select
    to authenticated
    using ((select auth.uid()) = user_id);
    create policy "Add own notes"
    on public.notes
    for insert
    to authenticated
    with check ((select auth.uid()) = user_id);
    create policy "Change own notes"
    on public.notes
    for update
    to authenticated
    using ((select auth.uid()) = user_id)
    with check ((select auth.uid()) = user_id);
    create policy "Delete own notes"
    on public.notes
    for delete
    to authenticated
    using ((select auth.uid()) = user_id);

    anon is anyone holding the publishable key who is not signed in. authenticated is a signed-in user. The policies let that user see and change only their own rows.

  6. Preview. This talks to the hosted project and changes nothing:

    Terminal window
    npx supabase db push --dry-run --remote

    You should see the new migration on the pending list, and no other files.

  7. Apply it. The question defaults to No. Type y. Pressing Enter declines, and the CLI exits with HostedMutationDeclinedError having changed nothing.

    Terminal window
    npx supabase db push --remote

    A script or CI job can’t answer the prompt. Pass --yes, or export SUPABASE_YES=1 in the shell that runs the command. A SUPABASE_YES line inside supabase/.env, .env, or .env.local does not count. If one of those files sets it at all, a shell export doesn’t count either: use --yes.

Warning

--include-seed loads supabase/seed.sql into the hosted database. Seed data is for a throwaway dev or staging project. Leave the flag off for production. npx supabase db reset --remote drops every table in the linked project and rebuilds it from the migration files. It is for a throwaway project only. Check npx supabase projects list for which project is linked before you run it.

--linked, --db-url, and --local still run, and the CLI warns that they go away in the next major version. Use --remote for the hosted project. If db push doesn’t accept --remote, the CLI is older than v3: npm install supabase@latest --save-dev.

Docker is only for a database on your machine. npx supabase start needs it, applies the migrations locally, and prints local URLs and keys. That stack has no TLS and uses default credentials. Use it to try a migration, then push to the hosted project. Don’t expose it.

Step 5: Or change the database in the dashboard

Use this when you don’t want the CLI yet, or for a one-off query. The SQL editor runs as a privileged database role, so it can see every row. That does not mean the API can.

  1. Open the project.
  2. Open SQL Editor, then New query.
  3. Paste the SQL from Step 4 (the create table through the four policies) and choose Run.
  4. You should see success, and Table Editor should list notes.

If this project will also use migrations, pull that change into git before anyone runs db push. Otherwise the hosted database and the migration history disagree, and the next push fails or tries to create the table again.

  1. Link the project if you haven’t (Step 4, items 1 to 4).

  2. Write a migration that matches the dashboard, and record it as already applied so a later push does not run it again:

    Terminal window
    npx supabase db pull --remote

    Confirm when it asks. Declining writes no file. Commit every file it adds under supabase/migrations/.

  3. On a machine with Docker, npx supabase db reset (no --remote) rebuilds your local database from those files so it matches the repo.

Do the next schema change in a new migration, not as a second untracked edit in the SQL editor.

Security

Caution

Security: the secret key skips row level security. It belongs in server environment variables and a password manager. A publishable key in the browser is expected. A secret key in the browser means anyone can read and write every row.

Walk this list before the project is used for anything real. The production checklist is the source. The steps below are that list, plus the grant and key rules that make it hold.

Keys and the database password

  • Publishable key (sb_publishable_…): browser code and NEXT_PUBLIC_ / VITE_ variables. Row level security applies.
  • Secret key (sb_secret_…): server code only. No public prefix. It connects as service_role.
  • Legacy eyJ keys: stop using them. Create the new keys, switch the app, then revoke the legacy ones under Project Settings → API Keys.
  • .env files: gitignored. Teammates get names from .env.example and values from you, or from 1Password (Configure for Code).
  • Database password: in the password manager, not in a command line and not in git. The CLI prompt or a shell SUPABASE_DB_PASSWORD is the way to pass it. Resetting the password from Connect or Project Settings → Database invalidates every current connection, including the pooler.
  • CLI access token: npx supabase login stores it on your machine. Don’t copy it into the repo or into CI logs. In CI, use a token from the account’s access tokens page, stored as a CI secret.
  • Leaked key: revoke it under Project Settings → API Keys, create a replacement, and update the environment variable. Assume every row was readable from the moment the secret key leaked.

Database

Row level security is off until you turn it on. A policy does not remove a grant. On many existing projects a new table in public is created with every privilege already granted to anon, authenticated, and service_role (select, insert, update, delete, and more). Newer projects may skip that. Check either way.

For every table in a schema the API exposes (public is exposed by default):

  1. Enable row level security in the same migration as create table:

    alter table public.notes enable row level security;
  2. Revoke the broad grants, then grant only the commands the app uses. Step 4 does this for notes: nothing for anon, and select, insert, update, and delete for authenticated. service_role keeps full access and bypasses the policies, which is why its key stays on the server.

  3. Add a policy per command (select, insert, update, delete) with a to role. A table with row level security on and no policy for a role returns no rows and allows no writes for that role. A missing grant fails earlier, with Postgres error 42501, before any policy runs.

  4. Prefer (select auth.uid()) inside a policy, as in Step 4. Postgres can then reuse the result instead of calling it on every row.

  5. Tables you add to a Realtime publication (Database → Publications) need the same row level security and policies. Row level security does not filter Realtime DELETE events: a subscribed client can learn that a row was deleted even when they were not allowed to see the row. Don’t publish a table whose deletes are sensitive, or don’t put private ids in the delete payload.

  6. Turn on SSL enforcement: Database → Settings → SSL Configuration. Database clients then have to use SSL.

  7. If the database should accept connections only from known networks, set Database → Settings → Network Restrictions to those ranges. This covers the direct Postgres port and the pooler. It does not cover the HTTPS APIs (Data API, Auth, Storage, Functions), which stay on the internet and rely on the keys plus row level security. After restrictions are on, an Edge Function can no longer open its own Postgres connection: call the Data API with @supabase/supabase-js instead. If the direct host is IPv6-only, allow both the IPv4 and IPv6 ranges you actually use.

config.toml is safe to commit when it still has the defaults. Secrets you add there should be env() references.

Account and organization

  1. Turn on multi-factor authentication for your own Supabase user (account menu → security). If you sign in with GitHub, turn on GitHub’s two-factor authentication. That is the second factor for this dashboard.
  2. On Pro, Team, and Enterprise, enforce multi-factor authentication for the organization, so a member can’t sign in with only a password. The toggle is in the organization security settings.
  3. Open Organization → Team and have at least two Owners. One Owner who loses their second factor should not be the only person who can recover the organization. Everyone else gets the smallest role that does their job. Owner can delete the organization and manage billing.

Sign-in

These live on Authentication → Sign In / Providers. Sign In / Providers is the click-by-click guide for email, magic links, codes, Google, Microsoft, and Resend. The hardening on that page is:

  1. Keep email confirmations on, so a new account has to prove it owns the address.
  2. Delete any test phone numbers. They accept a fixed code and are only for development.
  3. Set the email one-time code and magic-link lifetime to 3600 seconds or less.
  4. Turn on user multi-factor authentication when the app needs a second factor for its own users (this is separate from the dashboard factor above).
  5. Send mail through your own provider. Supabase’s built-in sender is for trying things out. The sign-in guide uses Resend.

Before you call it done

  1. Open Advisors in the project and clear every Security Advisor finding. The usual ones are a table with row level security off, or a policy missing.
  2. Read the app as an attacker would: what a signed-out person can do with the publishable key, what one signed-in user can do to another user’s rows, and what happens if the secret key leaks. The OWASP Top 10 is a good pass over the app itself (injection, broken access control, and the rest). Supabase does not do that pass for you.

Verify it works

  1. Preview again. There should be nothing left to apply:

    Terminal window
    npx supabase db push --dry-run --remote
  2. In the SQL Editor, list tables and whether row level security is on:

    select c.relname, c.relrowsecurity
    from pg_class c
    join pg_namespace n on n.oid = c.relnamespace
    where n.nspname = 'public' and c.relkind = 'r';

    notes should show relrowsecurity as true.

  3. Call the API the way a signed-out browser would. An empty list means anon cannot see rows:

    Terminal window
    curl "https://<your-project-ref>.supabase.co/rest/v1/notes?select=id" \
    -H "apikey: <your-publishable-key>" \
    -H "Authorization: Bearer <your-publishable-key>"

    You should see []. A JSON array of rows means row level security is off, or a policy allows anon.

  4. Open Advisors and confirm Security Advisor has no errors.

  5. After Sign In / Providers, sign in as a real user, insert a note, and repeat the curl while signed out. The signed-out call still returns []. Signed in, that user sees their own row and not someone else’s.

Troubleshooting

What you see What’s going on What to do
unknown flag: --remote The CLI is older than v3. npm install supabase@latest --save-dev, then run the command with npx supabase.
HostedMutationDeclinedError You pressed Enter. The confirm prompt defaults to No. Run it again and type y, or pass --yes.
HostedMutationConsentRequiredError The CLI can’t prompt (CI, or a non-interactive run). Nothing changed. Re-run with --yes once you mean to apply it.
Password authentication failed The database password doesn’t match, or it was reset. Reset it under Project Settings → Database, save the new one, and retry supabase link.
42501 permission denied The role has no grant for that command. Policies never get a chance to run. grant the command to authenticated (or anon, if signed-out visitors should have it).
The curl in Verify returns rows Row level security is off, or anon still has a policy or a grant you didn’t mean. Enable row level security, revoke all ... from anon, and check Advisors.
db push wants to create a table that already exists The table was made in the SQL editor and never recorded as a migration. npx supabase db pull --remote, confirm, and commit the file.
db push does nothing to the hosted project v3 targets the local stack unless you pass --remote. Add --remote. A local Docker database is a different database.
Can’t reach db.<your-project-ref>.supabase.co The direct host is IPv6-only. Use the session pooler string from Connect for ordinary clients. For db pull, use the direct host from a network that has IPv6, or the IPv4 add-on.
supabase start fails on [inbucket] A config.toml from before CLI 2.108.0. Rename the [inbucket] section to [local_smtp]. The keys inside stay the same.
Docker error on db push --remote Something else asked for the local stack. --remote does not need Docker. supabase start and a local db reset do.

Cleanup or rollback

  1. To drop a migration you have not pushed yet, delete its file under supabase/migrations/ and don’t push it.
  2. To undo a migration that is already on the hosted project, add a new migration that drops what you created (drop table if exists public.notes;) and push that. Editing an old file that has already been applied does nothing on the next push.
  3. To drop the link on this machine, delete supabase/.temp/. Keep supabase/migrations/ if you still want the SQL.
  4. To stop a project you might come back to, pause it from Project Settings → General. Pausing is not deleting. The data is still there when you restore it.
  5. To remove the project, open Project Settings → General → Delete project and type the project name. This deletes the database, the keys, and the auth users.
  6. Remove the URL and keys from .env, from the host’s environment settings, and from the password manager item if you’re finished with them.
  7. npx supabase db reset --remote erases the linked hosted database. Use it only on a throwaway project, and only when you intend to rebuild it from the migration files.

Dependencies

Versions

Tool Version Notes
Supabase CLI 3.2.0 --remote sends a database command to the hosted project. --linked and --db-url still run and are removed in the next major version. Checked 2026-11-22.
Node.js 20 or newer Required to install the CLI with npm.
@supabase/supabase-js 2.x The client in Step 3. Install with npm install @supabase/supabase-js.
Docker Current Only for npx supabase start and a local db reset. Not required to push.

References