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.

React SDK

Official AuthSafe SDK for React applications
v0.0.2
React 18+
TypeScript

Overview

The AuthSafe React SDK provides a complete set of hooks, components, and providers to implement secure authentication in your React applications. Built with TypeScript, it offers type-safe integration with OAuth 2.0 and OpenID Connect protocols.

Installation

Install the package using npm:
npm install authsafe-react

Quick Start

Follow these steps to get started:

1. Wrap your app with AuthProvider

import { AuthProvider } from 'authsafe-react';

function App() {
  return (
    <AuthProvider
      config={{
        clientId: 'your-client-id',
        redirectUri: 'http://localhost:3000/callback',
        scope: ['openid', 'profile', 'email'],
        env: 'production'
      }}
    >
      <YourApp />
    </AuthProvider>
  );
}

2. Use the hooks in your components

import { useLogin, useAuth, useLogout } from 'authsafe-react';

function MyApp() {
  const { login } = useLogin();
  const { user, isAuthenticated } = useAuth();
  const { logout } = useLogout();

  if (!isAuthenticated) {
    return <button onClick={() => login()}>Login</button>;
  }

  return (
    <div>
      <h1>Welcome, {user?.name}!</h1>
      <button onClick={logout}>Logout</button>
    </div>
  );
}
That's it!
Your React app now has secure authentication. Explore the individual hooks and components in the sidebar for detailed usage.

Available APIs

The React SDK provides the following hooks and components:
Providers
  • AuthProvider
    • Main provider component for configuration
Hooks
  • useLogin()
    • Trigger authentication flow
  • useLogout()
    • Sign out the current user
  • useAuth()
    • Access authentication state and user info
  • useAuthCallback()
    • Handle Auth redirect callback
Components
  • Profile
    • Pre-built user profile management component

Configuration Options

interface AuthConfig {
  clientId: string;              // Required: Your application's client ID
  redirectUri: string;            // Required: OAuth callback URL
  scope?: Array<AuthScope>;       // Optional: Requested scopes
  env?: 'development' | 'production';  // Optional: Environment
  authority?: string;             // Optional: Custom authority URL
  popupRedirectUri?: string;      // Optional: Popup redirect URL
  automaticSilentRenew?: boolean; // Optional: Auto-renew tokens
}
Next Steps
Explore the individual API documentation in the sidebar to learn more about each hook and component.