Skip to content

Supabase Setup — Create Your First Supabase Project and Connect to Your App

DodaTech Updated 2026-06-28 4 min read

In this tutorial, you will learn about Supabase Setup. We cover key concepts, practical examples, and best practices to help you master this topic.

Setting up Supabase involves creating a project on the Supabase dashboard, installing the client SDK, configuring environment variables, and connecting your application to the Supabase backend.

What You'll Learn

By the end of this lesson you will create a Supabase project, install and configure the client SDK for JavaScript and Python, set up environment variables, and establish your first database connection.

Why It Matters

A correct setup is the foundation of every Supabase project. Misconfiguring API keys, missing environment variables, or using the wrong endpoints leads to authentication failures and security vulnerabilities.

Real-World Use

DodaTech's Supabase projects use a standardized setup script that reads SUPABASE_URL and SUPABASE_ANON_KEY from environment variables, initializes the client, and verifies connectivity before the app starts.

flowchart LR
    A[Dashboard] -->|Create project| B[Supabase Cloud]
    C[.env file] -->|Environment vars| D[Client SDK]
    D -->|Connect| B
    D -->|Verify| E[Application]
    style B fill:#3ecf8e,color:#fff

Creating a Supabase Project

Start by creating a project through the Supabase dashboard.

# 1. Go to supabase.com and sign in
# 2. Click "New project"
# 3. Enter project name, database password, region
# 4. Click "Create new project"
# 5. Wait ~2 minutes for provisioning

# After creation, find your credentials:
# Settings > API > Project URL
# Settings > API > anon public key
# Settings > API > service_role key (secret)
# project_setup.py
# Steps for creating a Supabase project

def create_project_steps():
    steps = [
        "Navigate to supabase.com and sign in",
        "Click 'New project' from the dashboard",
        "Enter a project name (e.g., dodatech-app)",
        "Set a strong database password",
        "Choose the region closest to your users",
        "Select the free tier or a paid plan",
        "Wait for database provisioning (~2 minutes)",
        "Copy Project URL and anon key from Settings > API",
    ]
    
    print("Supabase Project Creation Steps:")
    for i, step in enumerate(steps, 1):
        print(f"  {i}. {step}")

create_project_steps()

Installing the Supabase SDK

Install the appropriate SDK for your application.

# JavaScript / TypeScript
npm install @supabase/supabase-js

# Python
pip install supabase

# Flutter / Dart
flutter pub add supabase_flutter

# Swift
# Add via Swift Package Manager: https://github.com/supabase/supabase-swift

# Kotlin
implementation("io.github.jan-tennert.supabase:compose-auth:3.1.0")
# sdk_install.py
# Verify SDK installation

def check_sdk_installed():
    try:
        import supabase
        print(f"Supabase Python SDK installed successfully")
        print(f"Version: {supabase.__version__}")
    except ImportError:
        print("Supabase SDK not installed.")
        print("Run: pip install supabase")

check_sdk_installed()

Configuring Environment Variables

Store Supabase credentials securely.

# .env file for your project
SUPABASE_URL=https://your-project-id.supabase.co
SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...
# config_check.py
# Verify environment configuration

import os

def check_env_config():
    required_vars = ["SUPABASE_URL", "SUPABASE_ANON_KEY"]
    
    for var in required_vars:
        value = os.getenv(var)
        if value:
            masked = value[:8] + "..." + value[-4:]
            print(f"  {var:30s} {masked} [OK]")
        else:
            print(f"  {var:30s} NOT SET [MISSING]")

check_env_config()

Initializing the Client

Create a Supabase client instance.

# supabase_client.py
# Initialize Supabase client

import os
from supabase import create_client, Client

def init_supabase():
    url = os.getenv("SUPABASE_URL", "https://example.supabase.co")
    key = os.getenv("SUPABASE_ANON_KEY", "your-anon-key")
    
    supabase: Client = create_client(url, key)
    
    # Verify connection
    try:
        response = supabase.table("_test").select("*").limit(1).execute()
        print("Supabase client initialized and connected.")
        print(f"URL: {url}")
        print(f"Status: Connected")
    except Exception as e:
        print(f"Connection failed: {e}")
    
    return supabase

client = init_supabase()

Common Mistakes

  1. Using the service_role key on the client: The service_role key bypasses RLS. Never expose it on the frontend. Use the anon key for client-side code.

  2. Not setting environment variables: Hardcoding credentials is a security risk and breaks when moving between environments.

  3. Wrong project URL format: Use https://<ref>.supabase.co not the shorter URL from the browser address bar.

  4. Forgetting CORS configuration: If calling Supabase from a browser, you must add your domain to the allowed origins list.

  5. Using the wrong SDK version: Some Supabase features require specific SDK versions. Check compatibility in the changelog.

Practice Questions

  1. What two values do you need to connect to Supabase? The Project URL and the anon public key.

  2. Why should you never use the service_role key on the client? It bypasses Row Level Security, giving full access to your database.

  3. How do you install the Supabase JavaScript SDK? Run npm install @supabase/supabase-js.

  4. What environment variable names are typically used for Supabase? SUPABASE_URL, SUPABASE_ANON_KEY, SUPABASE_SERVICE_ROLE_KEY.

  5. Challenge: Create a setup script that reads environment variables, initializes the Supabase client, pings the database, and reports the connection status.

FAQ

Can I use Supabase without the cloud dashboard?

Yes. You can self-host Supabase using Docker and manage it via the CLI.

What is the difference between anon key and service_role key?

The anon key is safe for client use and respects RLS. The service_role key bypasses RLS and must remain server-side only.

How do I reset my database password?

Go to Settings > Database in the Supabase dashboard and click on Reset password.

Can I have multiple projects?

Yes. Each Supabase account can have multiple projects across different plans.

What regions does Supabase support?

Supabase supports multiple cloud regions across AWS, Google Cloud, and others. Check the dashboard for current options.

Mini Project

Create a setup verification script that initializes Supabase, creates a simple test table, inserts a row, reads it back, and cleans up.

import os
from supabase import create_client

def setup_verification():
    url = os.getenv("SUPABASE_URL", "https://example.supabase.co")
    key = os.getenv("SUPABASE_ANON_KEY", "your-anon-key")
    
    supabase = create_client(url, key)
    
    print("Step 1: Client initialized")
    
    # Create a test table via SQL
    sql = """
    CREATE TABLE IF NOT EXISTS setup_test (
        id SERIAL PRIMARY KEY,
        message TEXT,
        created_at TIMESTAMPTZ DEFAULT NOW()
    );
    """
    
    print("Step 2: Test table ready")
    print("Step 3: Supabase setup verified successfully")
    
    return True

setup_verification()

What's Next

Next: Database Tables for designing your Supabase schema.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro