Skip to content

Overview

Learn about Nhost Auth

authentication auth login sign in sign up user management identity

Nhost Auth is a ready-to-use authentication service seamlessly integrated with the GraphQL API and its Permission System from Hasura. This allows you to easily add user authentication to your application without having to build and maintain your own authentication system.

Use the Nhost SDK to sign in users. For example, with email and password:

await nhost.auth.signIn({
email: 'user@example.com',
password: 's3cr3t',
});

To sign out the current user and invalidate their session:

await nhost.auth.signOut();

After a successful sign-in, Nhost Auth returns a session containing:

  • Access token - A short-lived JWT (default: 15 minutes) used to authenticate requests to the GraphQL API and Storage
  • Refresh token - A long-lived token (default: 30 days) used to obtain new access tokens

The session is typically handled by the client middleware or an authentication provider depending on the framework used. Refer to the quickstart guide for your framework for more details. However, you can refresh tokens with the SDK:

await nhost.auth.refreshToken({ refreshToken });