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

React SDK

SDK oficial de AuthSafe para aplicaciones React. integración de React con hooks, componentes y proveedores para una autenticación segura con OAuth 2.0 y OpenID Connect.

v0.0.2
React 18+
TypeScript

Overview

The authsafe-react SDK provides a full-featured authentication solution for React applications built on top of oidc-client-ts and TanStack Query. It handles all the complexity of OAuth 2.0 / OpenID Connect flows with a simple, declarative API.


Installation

npm install

npm install authsafe-react

Quick Start

Install the package using your preferred package manager:

1. Install the SDK

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. Wrap your app with AuthProvider

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>
  );
}
Ready to Go!
Once you've wrapped your app with AuthProvider, all hooks are available to use in any child component.

Available APIs

Explore the available APIs in the React SDK:

Providers
  • AuthProvider — Root authentication context provider
Hooks
  • useLogin() — Hook for triggering login flows
  • useLogout() — Hook for signing out users
  • useAuth() — Hook for accessing authentication state
  • useAuthCallback() — Hook for handling OAuth callbacks
Components
  • Profile — Pre-built 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
AuthSafe React SDK requires React 18+ and is compatible with any React framework including Next.js, Vite, and Create React App.

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.