New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@userfront/react

Package Overview
Dependencies
Maintainers
2
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@userfront/react

Transform your React application with Userfront authentication

latest
Source
npmnpm
Version
2.0.3
Version published
Weekly downloads
198
-22.96%
Maintainers
2
Weekly downloads
 
Created
Source



React SDK

The Userfront React SDK is a fast and easy way to use Userfront in your JavaScript or TypeScript React application.

For Node.js support on the server, see @userfront/node.

For Next.js support on the server and client, see @userfront/next.

Requirements

  • React v18 or later

Installation

npm install @userfront/react
# or
yarn add @userfront/react
# or
pnpm add @userfront/react

Add the UserfrontProvider with your desired tenantId to the root layout of your application.

import { UserfrontProvider } from "@userfront/react";

function Layout({ children }) {
  return (
    <html lang="en">
      <body>
        <UserfrontProvider tenantId="...">
          {children}
        </UserfrontProvider>
      </body>
    </html>
  );
}

Provider Options

OptionDefaultDescription
tenantIdstringThe tenant identifier, this can be found in workspace Tenants on the Userfront dashboard.
loginUrlstringRedirect URL for unauthenticated visitors that need to login, the default is /login.
loginRedirectstringRedirect URL after login, false to disable. When undefined, uses the path configured to the workspace paths & routing settings.
signupRedirectstringRedirect URL after signup, false to disable. When undefined, uses the path configured to the workspace paths & routing settings.
logoutRedirectstringRedirect URL after logout, false to disable. When undefined, uses the path configured to the workspace paths & routing settings.
requireAuthbooleanWhen true, unauthenticated visitors will be redirected to the loginUrl.

Usage

Hook

Use the useUserfront() hook to access Userfront core and the current client auth state.

import { useUserfront } from "@userfront/react";

export default function Component() {
  const { user, isLoading } = useUserfront();

  if (isLoading) {
    return <div>Loading...</div>;
  }

  return <div>Hello, {user.email}</div>;
}

In addition to core and the UserfrontProvider properties, these are also available for use:

PropertyTypeDescription
isAuthenticatedbooleanWhether or not the current visitor is signed into a valid user account.
isLoadingbooleanWhether or not Userfront has loaded and initialized.

Toolkit

Userfront toolkit components are included in this package. Import and use them without any necessary additional props:

import { LoginForm } from "@userfront/react";

export default function Component() {
  return <LoginForm />;
}

The available components are LoginForm, SignupForm, PasswordResetForm and LogoutButton.

Keywords

userfront

FAQs

Package last updated on 25 Apr 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts