nhost dev
starts your local development environment.
$ nhost dev
⠇ Nhost is starting...
# The first time dev is run takes a bit longer because the database is being created
✔ Local Nhost backend is running!
GraphQL API: http://localhost:8080/v1/graphql
Hasura Console: http://localhost:9695
Auth & Storage: http://localhost:9000
API: http://localhost:4000
The local websocket url is
ws://localhost:8080/v1/graphql
Great! You now have a Nhost backend locally with all services:
The Hasura console (http://localhost:9695
) was launched. Use this URL specifically to make changes in Hasura to track migrations and metadata automatically (recommended). All metadata and migrations are stored in the nhost/
folder.
Get local logs for each service when you develop locally.
$ docker logs -f nhost_postgres
$ docker logs -f nhost_hasura
$ docker logs -f nhost_hbp
$ docker logs -f nhost_api
Note that for the below configurations to take effect, you need to restart
nhost dev
.
To add permission variables to the JWT token set JWT_CUSTOM_FIELDS
in .env.development
.
Example: if every user has a company_id
column that should be used as a permission variable in the JWT token (x-hasura-company-id
):
JWT_CUSTOM_FIELDS=company_id
To add registration custom fields set REGISTRATION_CUSTOM_FIELDS
in .env.development
Example: If users should be able to set display_name
on registration.
REGISTRATION_CUSTOM_FIELDS=display_name
The docker containers all expose their ports directly on the host machine, so you can both reach them on localhost as well as on the host machine IP address from another machine connected to the same network (if firewall rules allows).
In Expo, to make development use the dev environment both in the simulator and in Expo Go and production use production, see code below:
export const URL =
Constants.manifest.packagerOpts.dev && !Constants.isDevice
? "http://localhost:9001"
: typeof manifest.packagerOpts === `object` && manifest.packagerOpts.dev
? `http://${manifest.debuggerHost.split(`:`).shift().concat(`:9001`)}`
: "nhost.io cloud url";