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

AuthSafe

Product

HighlightFeatureIntegrationPricingFAQ

Company

AboutBlogContactSitemap

Developer

DashboardDocumentation

Legal

Terms & ConditionsPrivacyComplianceShippingCancellation

© 2026 AuthSafe. All rights reserved.

We value your privacy

This website uses cookies for anonymous analytics to help us improve your experience. No personal information is stored or shared. You can allow or reject analytics tracking at any time. See our Privacy Policy.

We use cookies for anonymous analytics. No personal info is stored. See our Privacy Policy.

Profile Component

Full-featured profile management UI with tabs for profile details and security settings.

Overview

The Profile component is a ready-to-use, customizable profile page that includes:
  • User profile information display
  • Email verification status
  • Security settings with MFA management
  • Customizable branding (theme, colors, logo)
  • Loading and error states

Profile Component

Full-featured profile management UI with tabs for profile details and security settings.

Overview

The Profile component is a ready-to-use, customizable profile page that includes:
  • User profile information display
  • Email verification status
  • Security settings with MFA management
  • Customizable branding (theme, colors, logo)
  • Loading and error states
Server-Side Rendering
The Profile component is a client component, but you should fetch branding data server-side for optimal performance.

Props

interface ProfileProps {
  branding?: Branding;
  errorElement?: ReactNode;
  fallbackElement?: ReactNode;
}

interface Branding {
  theme: 'light' | 'dark';
  logoUrl: string | null;
  primaryColor: string;
  backgroundImage?: string | null;
}

branding (optional)

Brand customization fetched from AuthSafe server:
interface Branding {
  theme: 'light' | 'dark'; // Color theme
  logoUrl: string | null; // Company logo URL
  primaryColor: string; // Brand color (hex)
  backgroundImage?: string | null; // Optional background
}

errorElement (optional)

Custom element to display when user is not authenticated.

fallbackElement (optional)

Custom loading element while authentication state is being determined.

Usage

App Router (Server Component)

// app/profile/page.tsx
import Profile from 'authsafe-nextjs/client';
import { getAuth, initAuthSafe } from 'authsafe-nextjs/server';

initAuthSafe({
  clientId: process.env.NEXT_PUBLIC_AUTHSAFE_CLIENT_ID!,
  domain: process.env.NEXT_PUBLIC_AUTHSAFE_DOMAIN!,
});

export default async function ProfilePage() {
  const session = await getAuth();

  // Fetch branding server-side
  const response = await fetch(
    `${process.env.NEXT_PUBLIC_AUTHSAFE_DOMAIN}/auth/branding?client_id=${process.env.NEXT_PUBLIC_AUTHSAFE_CLIENT_ID}`,
    { cache: 'no-store' },
  );

  const branding = response.ok ? await response.json() : undefined;

  return <Profile branding={branding} />;
}

Pages Router

// pages/profile.tsx
import Profile, { Branding } from 'authsafe-nextjs/client';
import { GetServerSideProps } from 'next';

interface ProfilePageProps {
  branding?: Branding;
}

export default function ProfilePage({ branding }: ProfilePageProps) {
  return <Profile branding={branding} />;
}

export const getServerSideProps: GetServerSideProps = async () => {
  try {
    const response = await fetch(
      `${process.env.NEXT_PUBLIC_AUTHSAFE_DOMAIN}/auth/branding?client_id=${process.env.NEXT_PUBLIC_AUTHSAFE_CLIENT_ID}`,
    );
    const branding = await response.json();

    return { props: { branding } };
  } catch (error) {
    return { props: {} };
  }
};

Without Branding

import Profile from 'authsafe-nextjs/client';

export default function ProfilePage() {
  return <Profile />;
}

Custom Error Element

import Profile from 'authsafe-nextjs/client';
import Link from 'next/link';

export default function ProfilePage() {
  return (
    <Profile
      errorElement={
        <div className="flex flex-col items-center justify-center min-h-screen">
          <h1 className="text-2xl font-bold mb-4">Authentication Required</h1>
          <p className="text-gray-600 mb-6">
            Please sign in to view your profile
          </p>
          <Link
            href="/api/auth/signin"
            className="px-6 py-3 bg-blue-600 text-white rounded-lg hover:bg-blue-700"
          >
            Sign In
          </Link>
        </div>
      }
    />
  );
}

Custom Loading Element

import Profile from 'authsafe-nextjs/client';

export default function ProfilePage() {
  return (
    <Profile
      fallbackElement={
        <div className="flex items-center justify-center min-h-screen">
          <div className="text-center">
            <div className="inline-block w-16 h-16 border-4 border-blue-600 border-t-transparent rounded-full animate-spin mb-4" />
            <p className="text-gray-600">Loading your profile...</p>
          </div>
        </div>
      }
    />
  );
}

Fetching Branding

Branding should be fetched from the AuthSafe branding endpoint:
GET /auth/branding?client_id={clientId}
Response:
{
  "theme": "dark",
  "logoUrl": "https://cdn.example.com/logo.png",
  "primaryColor": "#3B82F6",
  "backgroundImage": null
}
Example:
const response = await fetch(
  `${process.env.NEXT_PUBLIC_AUTHSAFE_DOMAIN}/auth/branding?client_id=${process.env.NEXT_PUBLIC_AUTHSAFE_CLIENT_ID}`,
  { cache: 'no-store' },
);

const branding = await response.json();

Features

Profile Tab

Displays:
  • User avatar (generated from initials)
  • Full name
  • Email address with verification status
  • Profile metadata

Security Tab

Displays:
  • MFA status
  • Link to MFA management

Responsive Design

The Profile component is fully responsive and works on:
  • Desktop (full layout with sidebar)
  • Tablet (stacked layout)
  • Mobile (mobile-optimized layout)

Dark Mode

Dark mode is controlled by the branding.theme prop:
<Profile
  branding={{
    theme: 'dark',
    primaryColor: '#8B5CF6',
    logoUrl: null,
  }}
/>

Complete Example with Layout

// app/profile/page.tsx
import Profile from 'authsafe-nextjs/client';
import { getAuth, initAuthSafe } from 'authsafe-nextjs/server';
import { redirect } from 'next/navigation';

initAuthSafe({
  clientId: process.env.NEXT_PUBLIC_AUTHSAFE_CLIENT_ID!,
  domain: process.env.NEXT_PUBLIC_AUTHSAFE_DOMAIN!,
});

async function getBranding() {
  try {
    const response = await fetch(
      `${process.env.NEXT_PUBLIC_AUTHSAFE_DOMAIN}/auth/branding?client_id=${process.env.NEXT_PUBLIC_AUTHSAFE_CLIENT_ID}`,
      { cache: 'no-store' },
    );

    if (!response.ok) return undefined;

    return await response.json();
  } catch {
    return undefined;
  }
}

export default async function ProfilePage() {
  const session = await getAuth();

  if (!session) {
    redirect('/api/auth/signin?returnTo=/profile');
  }

  const branding = await getBranding();

  return (
    <div className="min-h-screen bg-gray-50">
      <nav className="bg-white shadow-sm border-b">
        <div className="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
          <div className="flex justify-between h-16">
            <div className="flex items-center">
              <h1 className="text-xl font-bold">My App</h1>
            </div>
          </div>
        </div>
      </nav>

      <main>
        <Profile branding={branding} />
      </main>
    </div>
  );
}

Customization

While the Profile component is pre-styled, you can:
  1. Wrap in custom layout - Add your own header/footer
  2. Override branding - Pass custom colors and theme
  3. Custom error/loading - Provide custom UI for loading/error states
For complete customization, use the useAuth() and useMfa() hooks to build your own profile page.

Related

  • useAuth() - Build custom profile pages
  • useMfa() - MFA management
  • Pre-built Components - Other ready-to-use components