/supabase-tutorials

How to connect Supabase to Hasura?

Connect Supabase to Hasura with this step-by-step guide. Learn to set up Supabase, retrieve credentials, install Hasura CLI, deploy via Docker, and verify your GraphQL connection.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to connect Supabase to Hasura?

 

Step 1: Set Up Supabase

 

Supabase is a backend-as-a-service platform that employs PostgreSQL for its database management. Begin by visiting the Supabase website and creating an account. Once logged in, create a new project:

  • Navigate to the Supabase dashboard.
  • Click on "New Project".
  • Provide your project details such as name and password.
  • Choose the region for your database.
  • Click "Create New Project" to initialize it.

Once the project is set up, you will get access to your project’s API details. These will be essential when connecting to Hasura.

 

Step 2: Access Supabase Database Credentials

 

To connect Supabase to Hasura, you need the database credentials. You can find these credentials in the Supabase dashboard:

  • Open the project dashboard.
  • Click on "Settings" and then "Database".
  • Locate your database connection URL. It will look something like this: postgres://username:password@host:port/database.

Take note of the username, password, host, port, and database name as you will need these to connect Supabase with Hasura.

 

Step 3: Install Hasura CLI

 

Hasura can be integrated with Supabase through its GraphQL API. First, you need to set up Hasura. Begin by installing the Hasura CLI on your system:

npm install --global hasura-cli

After installation, verify the installation by checking the version:

hasura version

Ensure you get an output showing the current version of the installed Hasura CLI.

 

Step 4: Deploy Hasura using Docker

 

Setting up Hasura usually involves using Docker, as it provides a straightforward setup process:

  • Create a docker-compose.yml file to configure Hasura with PostgreSQL. Insert the following content, replacing placeholders with your Supabase database details:

version: '3.6'
services:
  postgres:
    image: 'postgis/postgis:13-3.1'
    restart: always
    environment:
      POSTGRES\_PASSWORD: your-supabase-db-password
      POSTGRES\_USER: your-supabase-db-username
      POSTGRES\_DB: your-supabase-db-name
    ports:
    - '5432:5432'

  graphql-engine:
    image: hasura/graphql-engine:v2.0.0
    ports:
    - '8080:8080'
    depends\_on:
    - 'postgres'
    restart: always
    environment:
      HASURA_GRAPHQL_DATABASE\_URL: 'postgres://your-supabase-db-username:your-supabase-db-password@your-supabase-db-host:your-supabase-db-port/your-supabase-db-name'
      HASURA_GRAPHQL_ENABLE\_CONSOLE: 'true'
      HASURA_GRAPHQL_ADMIN\_SECRET: your-hasura-secret-key

To deploy, run:

docker-compose up -d

This command will start Hasura and connect it to your Supabase PostgreSQL instance.

 

Step 5: Access the Hasura Console

 

Once the containers are running, access the Hasura console to explore data and manage your schema:

  • Open your browser and visit http://localhost:8080
  • Log in with the admin secret key defined previously (your-hasura-secret-key).

The Hasura console will now be connected to your Supabase database, allowing you to interact with your data via GraphQL.

 

Step 6: Verify Connection and Manage Data

 

After setting up, it’s crucial to verify the connection with Supabase and explore Hasura’s features such as creating tables, managing permissions, and writing GraphQL queries:

To check if your tables have been successfully replicated:

  • Navigate to the "Data" tab in the Hasura console.
  • See if your existing Supabase tables appear. If they do, Hasura is correctly connected.

Now you can manage your database schema, set permissions, and write complex GraphQL queries directly within the Hasura console.

 

This step-by-step process helps you seamlessly connect Supabase with Hasura, leveraging the power of GraphQL to manage and streamline your backend operations.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022