Skip to main content

Nhost CLI

Nhost CLI, or nhost, is a command-line interface that lets you run and manage Nhost projects locally on Mac, Linux, and Windows (WSL2).

This means you get a full-featured Nhost project running locally on your machine:

  • Postgres Database
  • Hasura GraphQL API
  • Hasura Console
  • Authentication
  • Storage
  • Serverless Functions

This way, you can develop and test local changes before you deploy them. The CLI automatically tracks:

It's recommended to use Git for Nhost to automatically deploy changes to your Nhost project on git push.

Installation

To download and install Nhost CLI, run the following command:

sudo curl -L https://raw.githubusercontent.com/nhost/cli/main/get.sh | bash

Dependencies

The following dependencies are required:

  • Git
  • Docker (must be running while using the CLI)
info

Make sure you have the correct permissions for Docker so you don't have to run Docker with sudo. See "Post-installation steps for Linux" from Docker's documentation.

Get started

Start by authenticating yourself to Nhost Cloud:

nhost login

Once signed in, you can list all your Nhost projects using:

nhost list

Let's start by initializing a remote Nhost project locally with the following command:

nhost init --remote

Pick a Nhost project to use then change the directory once the project initialization is completed:

cd my_test_app

Then start the Nhost project locally:

nhost up

Hasura Console starts automatically and your Nhost project is running locally.

Subdomain and Region

Use localhost as the subdomain, and skip region when using the CLI and the JavaScript SDK:

import { NhostClient } from '@nhost/nhost-js'

const nhost = new NhostClient({
subdomain: 'localhost'
})

Emails

During local development with the CLI, all transactional emails from Nhost Authentication are sent to a local Mailhog services, instead of to the recipient's email address.

The Mailhog address is listed after starting nhost up:

$ nhost up
URLs:
- Postgres: postgres://postgres:postgres@localhost:5432/postgres
- GraphQL: http://localhost:1337/v1/graphql
- Auth: http://localhost:1337/v1/auth
- Storage: http://localhost:1337/v1/storage
- Functions: http://localhost:1337/v1/functions

- Hasura console: http://localhost:9695
- Mailhog: http://localhost:8025

- subdomain: localhost
- region: (empty)

What's next?