Overview
@wacht/react-router adds authentication, user management, and multi-tenancy to React Router v7 applications.
What’s Included
- Authentication Components - Pre-built sign-in, sign-up, and SSO callback components
- Authentication Hooks - Hooks for handling sign-in, sign-up, password reset, and more
- User Management - Hooks and components for profile management
- Organization & Workspace Support - Multi-tenant support with organizations and workspaces
- Session Management - Automatic session handling with token refresh
- Notifications - Real-time notification support with hooks and components
- AI Agents - Hooks for building AI agent features with context and integrations
Installation
Quick Start
1. Wrap Your Application
Wrap your application with theDeploymentProvider in your root route:
2. Create Sign-In and Sign-Up Routes
3. Protect Routes
4. Add User Menu
Configuration
Environment Variables
Set these environment variables in your React Router app:UI Customization
You can customize the UI by passinguiOverwrites to the provider:
Components
SignInForm
Complete sign-in form with email/password, OTP, magic link, and social authentication.SignUpForm
Complete sign-up form with validation and social authentication.UserButton
User profile dropdown with account management and sign-out.OrganizationSwitcher
Organization and workspace switcher for multi-tenant apps.SignedIn / SignedOut
Conditional rendering based on authentication state.Hooks
useSignIn
Handle user authentication with multiple strategies.useSignUp
Handle user registration.useSession
Access and manage user sessions.useUser
Manage user profile and settings.useOrganization
Manage organizations and memberships.useWorkspace
Manage workspaces within organizations.useNavigation
Navigate between authentication pages and routes.API Reference
Components
| Component | Description |
|---|---|
SignInForm | Complete sign-in form component |
SignUpForm | Complete sign-up form component |
UserButton | User profile dropdown |
OrganizationSwitcher | Organization/workspace switcher |
ManageAccount | Account management component |
ManageOrganization | Organization management component |
CreateOrganizationForm | Create organization form |
CreateWorkspaceForm | Create workspace form |
SignedIn | Render children only when signed in |
SignedOut | Render children only when signed out |
SSOCallback | OAuth/SSO callback handler |
WaitlistForm | Waitlist signup form |
MagicLinkVerification | Magic link verification handler |
NotificationBell | Notification bell icon |
NotificationPopover | Notification popover |
NotificationPanel | Full notification panel |
Hooks
| Hook | Description |
|---|---|
useSignIn | Handle user sign-in |
useSignUp | Handle user sign-up |
useSession | Access and manage session |
useUser | Manage user profile |
useDeployment | Access deployment settings |
useClient | Access configured HTTP client |
useNavigation | Manage navigation redirects |
useForgotPassword | Handle password reset |
useMagicLinkVerification | Handle magic link authentication |
useSSOCallback | Handle OAuth callbacks |
useWaitlist | Handle waitlist signup |
useOrganizationList | List user’s organizations |
useActiveOrganization | Access active organization |
useOrganizationMemberships | Manage organization memberships |
useWorkspaceList | List workspaces |
useActiveWorkspace | Access active workspace |
useWorkspaceMemberships | Manage workspace memberships |
useNotifications | Access notifications |
useNotificationStream | Real-time notification stream |
useAgentContext | Access AI agent context |
useAgentSession | Access AI agent session |
useInvitation | Handle organization invitations |
Examples
Complete Authentication Flow
Protected Routes
Organization Management
Related
- Next.js SDK - Next.js SDK documentation
- TanStack Router SDK - TanStack Router SDK documentation
- API Reference - Frontend API reference
