Skip to main content
Version: v2.x

Connecting Hasura to a Neon Serverless Postgres Database

Introduction

This guide explains how to connect a new Neon serverless Postgres database to a Hasura Cloud instance.

Creating a New Neon Database

Step 1: Sign up or log in to Hasura Cloud

Navigate to Hasura Cloud and sign up or log in.

Step 2: Create a Hasura Cloud project

On the Hasura Cloud dashboard, create a new project:

Create Hasura Cloud project

After the project is initialized successfully, click on Launch Console to open the Hasura Console in your browser.

On the Hasura Console, navigate to Data -> Manage -> Connect Database -> Create New Database:

Click on Connect Neon Database to create and connect a new Postgres database to your Hasura project.

Connect Neon database

On the next step, you'll be prompted to Login/Sign up for Neon. We recommend Continue with Hasura for a seamless experience.

Neon Authentication

After successful authorization, a new Neon Postgres database will be created and connected to your Hasura project with the connection string associated with the environment variable PG_DATABASE_URL.

Step 3 (optional): Load a template

Once the database is successfully connected, you can explore Hasura's GraphQL API by loading any of the templates from the template gallery instantly.

For example: to get started, you could try the Welcome to Hasura template:

Hello World Template

This installs a schema with data that you can now query using your Hasura GraphQL API from the API tab.

Voilà! You are ready to start developing.

Hasura Console
Note

You can visit the Neon console from the Data tab to manage your created database.

Neon Console Link

Migrating an existing database to Neon

If you want to migrate your existing database to Neon, you must use Postgres's pg_dump utility to copy over your database.

pg_dump -h <host> -U <username> <dbname> | psql -h pg.neon.tech

For more info, follow Neon's detailed guide for importing a database.

Note

If you're migrating from Heroku, check out Neon's platform-specific migration guide.

Neon Free Tier

With Neon's Free Tier, you can create up to three projects with the following limits:

  • Project data size is limited to 10GB
  • The Point in Time Reset (PITR) window is limited to 7 days of reasonable usage
  • The compute node is limited to 1 vCPU and 256MB of RAM

For more info, check out Neon's Technical Preview Free Tier.

Note

If you've already reached the free-tier limit of three databases, please head to your Neon console and delete an unused database to be able to create and connect a new one from the Hasura Console.

Neon Free Tier Warning
Note

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