Client Side

AuthProvider

The AuthProvider is the heart of your client-side authentication. It wraps your application to provide context, state, and security helpers to all child components.

Usage

Wrap your root layout (or specific route groups) with the provider:

terminal
import { AuthProvider } from "@ezz-auth/next";

export default function RootLayout({ children }) {
  return (
    <AuthProvider>
      {children}
    </AuthProvider>
  );
}

Responsibilities

User Hydration

Automatically fetches and loads the authenticated user profile on application mount.

State Management

Maintains a global, reactive authentication state throughout the entire component tree.

Hook Integration

Seamlessly exposes internal data and methods to hooks like useUser() and useAuth().

Security by Design

No Token Exposure

Tokens are never accessible via JavaScript, preventing sensitive data leakage via XSS.

Server-Validated

Every state change is backed by a server-side session validation to prevent UI spoofing.