Skip to main content
Version: v2.x

Connecting Hasura to a Prisma Postgres Database

Introduction

This guide explains how to connect a new or existing Prisma Postgres database to a Hasura instance.

Step 1: Sign up or log in to Prisma Postgres

Navigate to the Prisma Postgres console and sign up or log in.

Step 2: Create a new Prisma Postgres Project

Click the New Project button.

Prisma Postgres console showing the New Project button

Input the proper credentials you'd like to use for your project.

Prisma Postgres project creation form with input fields for project credentials

Click Create Project.

You should now see your new project in the Prisma Postgres console.

Step 3: Generate Credentials

From the project sidebar, click the Dashboard button, then press Connect.

Prisma Postgres dashboard with Connect button highlighted

Switch to the Any Client (Preview) tab.

Click the Generate Credentials button to get the database connection string.

Prisma Postgres TCP credentials page with connection string and Generate Credentials button

Congratulations! You've now created a Postgres instance on Prisma Postgres which you can use with Hasura GraphQL Engine.

Step 4: Sign up or log in to Hasura Cloud

Navigate to Hasura Cloud and sign up or log in.

Step 5: Store the database connection string in Hasura Cloud

On the Hasura Cloud dashboard, create a new project:

Hasura Cloud dashboard with Create Project button

After the project is initialized successfully, click on Env Vars, then New Env Var to import the database connection string you generated in the previous section.

Hasura Cloud environment variables page with New Env Var button

From there, give your env var a name like DATABASE_URL, paste in the database connection string, and press Save.

Step 6: Launch the Hasura Console

Click on Launch Console to open the Hasura Console in your browser.

Hasura Cloud project dashboard with Launch Console button

Step 7: Connect the database to Hasura Cloud

On the Hasura Console, navigate to the Data tab and press Connect Database at the top.

Hasura Console Data tab with Connect Database button

From there, select Postgres and press Connect Existing Database.

Hasura Console database connection page with Postgres selected and Connect Existing Database button

Enter the name of your Env Var you created earlier, then press Connect Database.

Hasura Console database connection form with environment variable input field and Connect Database button

That's it! You're now connected to your Prisma Postgres database and can start building.

Next steps

Project actions
Note

For more information on which Postgres features we support, check out this page.