Next.js Guide

Next.js Multi-Tenant Auth

Build multi-tenant Next.js applications with GitHat. Organization switching, role-based access, team invitations, and scoped API tokens.

Multi-Tenancy with GitHat

Build SaaS apps with Next.js and GitHat. Every user can create and join multiple organizations. The OrgSwitcher component lets users switch between orgs seamlessly.

Org Switcher Component

The OrgSwitcher component lists all orgs the user belongs to. Clicking an org calls switchOrg() which gets new tokens scoped to that org. The entire app context updates instantly.

Role-Based UI

Use useAuth() to access the current user's org role. Conditionally render admin panels, invite forms, and settings pages based on whether the user is an owner, admin, or member.

Install

npm install @githat/nextjs

Example

// Dashboard header with org switching
'use client';
import { useAuth, OrgSwitcher, UserButton } from '@githat/nextjs';

export function DashboardHeader() {
  const { user, org } = useAuth();
  return (
    <header>
      <span>{org?.name}</span>
      <OrgSwitcher />
      <UserButton />
      {org?.role === 'owner' && <a href="/settings/billing">Billing</a>}
    </header>
  );
}
Try GitHat free

Ship authenticated apps in minutes, not weeks.