▲ Vercel Integration now GA - Create a database branch for every preview deployment, automatically.Learn here
Guides/Backend-as-a-service

Connect from Hasura Cloud to Neon

Learn how to connect a Hasura Cloud project to a new or existing Neon database

Hasura Cloud is an open source GraphQL engine that provides a scalable, highly available, globally distributed, secure GraphQL API for your data sources.

Connecting to a new Neon database

Use the following instructions to connect to a new Neon database. This connection method authenticates you from Hasura Cloud.

  1. Navigate to Hasura Cloud and sign up or log in.
  2. On the Hasura Cloud dashboard, create a Hasura project.
  3. After the project is initialized, click Launch Console to open the Hasura Console.
  4. On the Hasura Console, navigate to DATA > Manage > Connect Database > Create New Database.
  5. Click Connect Neon Database.
  6. When prompted to login or sign up for Neon, we recommend selecting Continue with Hasura for seamless authentication.

After authenticating, a new Neon Postgres database is created and connected to your Hasura project, and the Neon project connection string is associated with the PG_DATABASE_URL environment variable.

To start exploring Hasura's GraphQL API with data stored in Neon, see Load a template in Hasura.

Connecting to an existing Neon database

Use the following instructions to connect to an existing Neon database from Hasura Cloud. The connection is configured manually using a connection string.

Prerequisites

  • An existing Neon account. If you do not have one, see Sign up.

  • An existing Neon project. If you do not have a Neon project, see Create a project.

  • A connection string for a branch in your Neon project:

    postgres://[user]:[password]@[neon_hostname]/[dbname]

    Your project's connection string can be found on the Neon Dashboard, under Connection Details. For more information, see Connect from any application.

Add Neon as a data source

The following steps describe how to navigate to Hasura Cloud and connect to your Neon project.

  1. Navigate to Hasura Cloud and sign up or log in.
  2. Click Create Project to create a Hasura Cloud project or click Launch Console to open an existing project.
  3. Select DATA from the top navigation bar.
  4. On the Connect Existing Database tab, paste your connection string into the Database URL field.
  5. Enter a display name for your database in the Database Display Name field, and click Connect Database.

Hasura Cloud connects to your Neon project and automatically discovers the default public schema.

To start exploring Hasura's GraphQL API with data stored in Neon, see Load a template in Hasura.

Load a template in Hasura (optional)

Optionally, after connecting from your Hasura project to Neon, you can explore Hasura's GraphQL API by loading a template from Hasura's template gallery. Follow these steps to load the Welcome to Hasura template, which creates customer and order tables and populates them with sample data.

  1. In the Hasura Console, select DATA.
  2. Under Data Manager, select your database.
  3. From the Template Gallery, select Welcome to Hasura to install the template.

To view the newly created tables from the Neon Console:

  1. In the Hasura Console, select DATA > Manage your Neon databases to open the Neon Console.
  2. In the Neon Console, select your project.
  3. Select the Tables tab. The newly created customer and order tables should appear under the Tables heading in the sidebar.

Import existing data to Neon

If you are migrating from Hasura with Heroku Postgres to Neon, refer to the Import data from Heroku guide for data import instructions. For general data import instructions, see Import data from Postgres.

Need help?

Join our Discord Server to ask questions or see what others are doing with Neon. Users on paid plans can open a support ticket from the console. For more detail, see Getting Support.

Last updated on

Edit this page
Was this page helpful?