Node.js Guide

Node.js Authentication

Integrate GitHat authentication into any Node.js application. REST API for user management, JWT tokens, and organization-scoped access control.

GitHat for Node.js

Add auth to Node.js without building it from scratch. GitHat handles registration, login, email verification, password reset, and org management via a simple REST API.

API Integration

GitHat's API endpoints: register, login, logout, refresh tokens, get current user, verify email, reset password, manage orgs. All available at api.githat.io.

Token Management

Access tokens expire in 15 minutes for security. Refresh tokens last 7 days. Call /auth/refresh with the refresh token to get new tokens. Session rotation prevents token reuse.

Install

npm install node-fetch

Example

// auth.js
const GITHAT_API = 'https://api.githat.io';

async function register(email, password, name) {
  const resp = await fetch(`${GITHAT_API}/auth/register`, {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({ email, password, name })
  });
  return resp.json();
}

async function validateToken(accessToken) {
  const resp = await fetch(`${GITHAT_API}/auth/me`, {
    headers: { Authorization: `Bearer ${accessToken}` }
  });
  return resp.ok ? resp.json() : null;
}
Try GitHat free

Ship authenticated apps in minutes, not weeks.