npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@the91end/react-auth

v1.0.0

Published

Authentication library for React.

Downloads

13

Readme

ReactAuth

Live Demo: http://reactauth.com/demo/


ReactAuth is a simple to use authentication module for React with built-in support for login (username/password and social), registration, forgotten password, and more.

Table of Contents

Installation

The easiest way to get ReactAuth is by running one of the following commands:

# Bower
bower install react-auth

# NPM
npm install react-auth

Alternatively, you may download the latest release or use the CDN:

<!--[if lte IE 9]>
<script src="//cdnjs.cloudflare.com/ajax/libs/Base64/0.3.0/base64.min.js"></script>
<![endif]-->
<script src="//cdn.jsdelivr.net/react-auth/1.0.0/react-auth.min.js"></script>

If installed via Bower, include one of the following script tags:

<script src="bower_components/react-auth/react-auth.js"></script>
<!-- or -->
<script src="bower_components/react-auth/react-auth.min.js"></script>

Note: ReactAuth depends on window.atob() for decoding JSON Web Tokens. If you need to support IE9 then use Base64 polyfill above.

Usage

Step 1. Initialize the module

ReactAuth.init({
	// Configuration...
});

Step 2. Import and add components to your page

import { LoginForm } from 'react-auth';

class LoginPage extends React.Component {
    render() {
        return (
            <div id="login-page">
                <LoginForm />
            </div>
        );
    }
}

Configuration

Below is a complete list of all configuration options.

// Configure ReactAuth with your own AuthProvider
ReactAuth.init({
	authProvider: customAuthProvider
});

// Configure ReactAuth with a specific/supported AuthProvider.
// Supported providers currently are 'stormpath' or 'default'.
ReactAuth.init({
	authProvider: {
		use: 'stormpath'
	}
});

Authentication Flow

Login with Credentials

This describes how the credentials (username/password) login flow works.

Login with Social Provider

This describes how the social provider (facebook, google, github) login flow works.

Logout

This describes how the logout flow works.

Authentication Providers

Default

Authenticate using your own REST API.

ReactAuth.init({
	// Below is what is being used when you don't configure the authProvider.
	authProvider: {
		use: 'default'
	}
});

Stormpath

Authenticate using Stormpath - The Identity and User Management API.

ReactAuth.init({
	authProvider: {
		use: 'stormpath'
	}
});

Create your own

Currently not available. See the StormpathAuthProvider for a reference implementation.

Integrations

ReactRouter

Components

API Reference

isAuthenticated()

Checks authentication status of a user.

Usage
import { isAuthenticated } from 'react-auth/actions';

isAuthenticated().then((authenticated) => {
  console.log(authenticated ? 'Authenticated!' : 'Not authenticated!');
});

loginWithCredentials(credentials)

Sign in using Email and Password.

Parameters

| Param | Type | Details | ------------------------ | -------- | --------------------------------------------------------------------------------------- | credentials | Object | JavaScript object containing credentials to login with.

Returns
  • response - The HTTP response object from the server.
Usage
import { loginWithCredentials } from 'react-auth/actions';

let user = {
  email: '[email protected]',
  password: 'my password'
};

loginWithCredentials(user)
  .then(function(session) {
    // E.g. redirect user here after a successful log in.
  })
  .catch(function(response) {
    // Handle errors here, such as displaying a notification
    // for invalid email and/or password.
  });

loginWithSocialProvider(options)

Sign in using a social provider (such as Facebook, Google or LinkedIn).

Parameters

| Param | Type | Details | ------------------------ | -------- | --------------------------------------------------------------------------------------- | options | Object | JavaScript object containing details about the social provider to login with.

Returns

Redirects automatically to the social provider for authentication.

Usage
import { loginWithSocialProvider } from 'react-auth/actions';

let options = {
  providerId: 'google'
};

loginWithSocialProvider(options)
  .catch(function(err) {
    // Handle errors here, such as displaying a notification
    // for invalid provider options.
  });

signup(user)

Create a new account with Email and Password.

Parameters

| Param | Type | Details | ------------------------ | -------- | --------------------------------------------------------------------------------------- | user | Object | JavaScript object containing user information.

Returns
  • response - The HTTP response object from the server.
Usage
import { signup } from 'react-auth/actions';

var user = {
  firstName: 'Test',
  lastName: 'Testersson',
  email: '[email protected]',
  password: 'my password'
};

signup(user)
  .then(function(response) {
    // Redirect user here to login page or perhaps some other intermediate page
    // that requires email address verification before any other part of the site
    // can be accessed.
  })
  .catch(function(response) {
    // Handle errors here.
  });

logout()

End the current session.

Usage
import { logout } from 'react-auth/actions';

logout();

License

APACHE-2. See LICENSE.