Nextbase Docs
Installation

Setting up Supabase Locally

Learn how to set up Supabase locally for development. This guide will show you how to pull the Docker image and set up the environment variables for your Next.js application.

To get started with Supabase locally, you will just need to pull the docker image. Here's how to do it:

Setting up Docker for Supabase

  1. First, you will need to install Docker on your machine. You can download the installer from the Docker website since it is the recommended way to install Docker on Windows and macOS. If you are using Linux, you can follow the instructions for your specific distribution on the Docker documentation.
  2. Next, you will need to setup the env variables.

In your repository directory, you should have a .env.local.example file which looks like this. For dev environment, just copy the .env.local.example file to .env.local. The localhost values are used for local development.So nothing needs to change here.

    # supabase
    # These values never change when supabase is ran locally regardless of project
    NEXT_PUBLIC_SUPABASE_URL=http://localhost:54321/
    NEXT_PUBLIC_SUPABASE_ANON_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0
    SUPABASE_SERVICE_ROLE_KEY=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU
    SUPABASE_DATABASE_PASSWORD=postgres
    SUPABASE_JWT_SECRET=super-secret-jwt-token-with-at-least-32-characters-long
    # SUPABASE_PROJECT_REF=SUPABASE_PROJECT_REF
    # stripe
    STRIPE_SECRET_KEY=STRIPE_SECRET_KEY
    NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY
    STRIPE_WEBHOOK_SECRET=STRIPE_WEBHOOK_SECRET
    # host
    NEXT_PUBLIC_SITE_URL=http://localhost:3000
    # email
    ADMIN_EMAIL=admin@myapp.com
    RESEND_API_KEY=RESEND_API_KEY
    # analytics
    # ultimate and pro
    NEXT_PUBLIC_POSTHOG_API_KEY=NEXT_PUBLIC_POSTHOG_API_KEY
    NEXT_PUBLIC_POSTHOG_APP_ID=NEXT_PUBLIC_POSTHOG_APP_ID
    NEXT_PUBLIC_POSTHOG_HOST=NEXT_PUBLIC_POSTHOG_HOST
    NEXT_PUBLIC_GA_ID=NEXT_PUBLIC_GA_ID
    UNKEY_ROOT_KEY=UNKEY_ROOT_KEY
    UNKEY_API_ID=UNKEY_API_ID
    ## Supabase providers
    # this file is only used by supabase configtoml for local development
    # next.js uses .env.local for local development
    TWITTER_API_KEY=TWITTER_API_KEY
    TWITTER_API_SECRET=TWITTER_API_SECRET
    GOOGLE_CLIENT_ID=GOOGLE_CLIENT_ID
    GOOGLE_CLIENT_SECRET=GOOGLE_CLIENT_SECRET
    GITHUB_CLIENT_ID=GITHUB_CLIENT_ID
    GITHUB_CLIENT_SECRET=GITHUB_CLIENT_SECRET

Note. Supabase also reads from .env.local for local development. If you don't need to setup social providers like github, google yet, just leave the dummy values in env.local file. Removing the values will however break supabase start, since the config.toml has social providers enabled by default. Either disable them in config.toml or leave the dummy values. Read more here.

  1. Once you have Docker installed and running in your machine, you can now pull the Supabase Docker image by running pnpm supabase start in your terminal.

Please note that for the first time you run the pnpm supabase start command, it will take some time to pull the Docker image. Subsequent runs will be faster since the images will be cached and volumes will be persisted.

  1. After running the command, you should see the output simmilar to the following:
Terminal Output for [pnpm supabase start]
Status: Downloaded newer image for public.ecr.aws/supabase/studio
Started supabase local development setup.
 
         API URL: http://localhost:54321
     GraphQL URL: http://localhost:54321/graphql/v1
          DB URL: postgresql://postgres:postgres@localhost:54322/postgres
      Studio URL: http://localhost:54323
    Inbucket URL: http://localhost:54324
      JWT secret: super-secret-jwt-token-with-at-least-32-characters-long
        anon key: anon-key-for-local-development
service_role key: service-role-key-for-local-development
  1. You can now access the Supabase Studio by visiting the URL http://localhost:54323 in your browser.
  2. You can also access the API and GraphQL URLs to interact with your local Supabase instance.
  3. To connect database clients to your local Supabase instance, you can use the DB URL postgresql://postgres:postgres@localhost:54322/postgres
  4. To monitor your inboxes, you can use the Inbucket URL http://localhost:54324
  5. You can stop the Supabase server by running the pnpm supabase stop command, to save on system resources.

On this page