RegisterLogin
DocsPricing
RegisterLogin
  • Getting Started
  • Introduction
  • Quick Start
  • SDKs
  • React
  • TypeScript
  • Next.js
  • Express
  • NestJS
  • Python
  • API Reference
  • Support and Resources
  • FAQ
  • Contact

useSession()

Lightweight hook for accessing the current user session. Simplified alternative to useAuth() when you only need session data.


Overview

The useSession() hook provides access to the current session with properties: session (current user session or null), isLoading (whether session is being loaded), and error (error if session loading failed). Use this when you only need to read session data without sign in/out functionality.


Basic Usage

'use client';
import { useSession } from 'authsafe-nextjs';

export default function UserProfile() {
  const { session, isLoading } = useSession();

  if (isLoading) return <p>Loading...</p>;
  if (!session) return <p>Not signed in</p>;

  return (
    <div>
      <p>{session.name}</p>
      <p>{session.email}</p>
    </div>
  );
}

Best Practices
  • Use useSession() when you only need to read session data
  • Use useAuth() when you need sign in/out methods
  • For server components, use getAuth() instead

AuthSafe

Product

HighlightFeatureIntegrationPricingFAQ

Company

AboutBlogContact

Developer

DashboardDocumentation

Legal

Terms & ConditionsPrivacyComplianceShippingCancellationAI

© 2026 AuthSafe. All rights reserved.

Valoramos su privacidad

Este sitio web utiliza cookies para análisis anónimos que nos ayudan a mejorar su experiencia. No se almacena ni comparte información personal. Puede permitir o rechazar el seguimiento analítico en cualquier momento. Consulte nuestra Política de Privacidad.

Usamos cookies para análisis anónimos. No se almacena información personal. Consulte nuestra Política de Privacidad.