Docs
Database
Supabase Setup

Setting Up Supabase

Supabase is an open-source database provider and backend service that offers a full Postgres database, authentication, and many other features. Postgres is considered one of the world's most stable and advanced databases.

Our project's database will run on Supabase. It's cost-effective (you can start with a free account) and is production-grade. We will also manage authentication with Supabase.

Steps to Set Up Supabase

  1. Create an account on Supabase (opens in a new tab).

  2. Create a new organization.

    supabase_step1
  3. Create a new project:

    supabase_step2
    • Give your project a name and enter a database password.
    • Select a region that is closest to your target audience (e.g., Ireland is close to both America and Europe, which is ideal if most of your visitors come from these regions).
    • Create the project.
  4. Retrieve your project API keys:

    supabase_step3
    • Once the project is created, you will be presented with the project API keys.
    • If not, navigate to Project Settings > Configuration > API.
  5. Set up your environment variables:

    supabase_step4
    • Go to .env.local in the root directory of your Next.js project folder (if it doesn’t exist, rename .env.example in the same root folder to .env.local).
    • Copy the Project URL and paste it inside .env.local:
      NEXT_PUBLIC_SUPABASE_URL=your-project-url
    • Copy the anon public API key and paste it inside .env.local:
      NEXT_PUBLIC_SUPABASE_ANON_KEY=your-anon-public-api-key
    • Copy the service role secret API key and paste it inside .env.local:
      SUPABASE_SERVICE_ROLE_KEY=your-service-role-secret-api-key
    • If you're working in a live server, you might configure these keys differently, such as within the server's environment variable settings.

Note: Ensure the .env.local file is included in your .gitignore to keep it from being pushed to GitHub. Keep all these keys safe by storing them inside the environment file only and never sharing them with anyone.

That's it! Your Supabase setup is complete! πŸ˜„