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 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-easy-auth

v1.0.2

Published

Easily add authentication with firebase to your React application.

Downloads

7

Readme

react-easy-auth

A React component that easily adds social authentication with firebase to your projects.

NPM JavaScript Style Guide

showcase video

Install

npm install --save react-easy-auth

Configuration

  1. Use an existing firebase project or create a new one. Then enable your preferred sign-in method from the firebase console. For help visit: https://firebase.google.com/docs/web/setup
  2. Paste your firebase configuration in a .env file inside your React project:
REACT_APP_APIKEY="api-key"
REACT_APP_AUTHDOMAIN="project-id.firebaseapp.com"
REACT_APP_DATABASEURL="https://project-id.firebaseio.com"
REACT_APP_PROJECTID="project-id"
REACT_APP_STORAGEBUCKET="project-id.appspot.com"
REACT_APP_MESSAGINGSENDERID="sender-id"
REACT_APP_APPID="app-id"

Usage

import React, { useState } from 'react'

import { SocialSignIn, SocialSignOut } from 'react-easy-auth'

export const App = () => {
  const [user, setUser] = useState(null)

  //a method to fetch user data from the SocialSignIn component
  const fetchUserData = (userData, userCredentials, error) => {
    if (!error) {
      setUser(userData)
    }
  }

  // a method to handle sign-out 
  const onSignOut = (error) => {
    if (!error) {
      console.log('signed out')
      setUser(null)
    }
  }

// if the user data is present we show the SocialSignOut Compononent
  if (user) {
    return (
      <div>
        <h1> Welcome {user.displayName} </h1>
        <SocialSignOut style={{ color: 'red' }} onSignOut={onSignOut} />
      </div>
    )
  }

// if there is no user data we show the SocialSignIn Component
  return (
        <SocialSignIn
          authProvider='Google'
          style={{ color: 'white', backgroundColor: 'red', fontSize: '20px', borderRadius: '5px' }}
          fetchUserData={fetchUserData}
        />
  )
}

API

SocialSignIn

authProvider

| Type | Required |
| :------------- | :----------: | | string | Yes |

This prop is used to describe what authentication provider needs to be activated. Make sure to also enable the same from firebase console. The available providers are:

  • Google
  • Twitter
  • Facebook
  • Github
  • Microsoft

fetchUserData()

| Type | Parameters | Required |
| :------------- | :------------------------------------: | :----------: | | function | userData, userCredentials, error | Yes |

This function is used as a prop to fetch the data from the SignIn Component whenever a user signs in.

  • userData (Object): The user related data.
  • userCredentials (Object): The user credentials like access tokens
  • error (Object): Error generated during the authentication flow

style

| Type | Required |
| :------------- | :---------------: | | object | Optional |

This prop is used to add styling to the SocialSignIn button using inline CSS. You can add your preffered styling to the button to give it a custom appeal.

scopes

| Type | Required |
| :------------- | :---------------: | | array | Optional |

This prop is used to specify additional OAuth 2.0 scopes that you want to request from the. authentication provider.

SocialSignOut

onSignOut()

| Type | Parameters | Required |
| :------------- | :----------: | :----------: | | function | error | Yes |

This function is used as a prop to activate the sign out method. If any error occurs during the process it is returned through the error object.

  • error (Object): Error generated during the sign out flow

style

| Type | Required |
| :------------- | :---------------: | | object | Optional |

This prop is used to add styling to the SocialSignOut button using inline CSS. You can add your preffered styling to the button to give it a custom appeal.

Contributing

See contributing guidlines here

License

MIT © chiragsrvstv