JSPM

delta-react-google-authentication

1.1.5
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 2
    • Score
      100M100P100Q37924F
    • License MIT

    Google Sign-In authentication package for React, integrated with delta-google-authentication backend

    Package Exports

    • delta-react-google-authentication
    • delta-react-google-authentication/src/index.js

    This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (delta-react-google-authentication) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

    Readme

    delta-react-google-authentication

    Google Sign-In authentication package for React applications integrated with delta-google-authentication backend.

    🚀 Installation

    npm install delta-react-google-authentication

    📌 Setup

    You need a backend running delta-google-authentication.

    🔹 Usage

    1️⃣ Import the GoogleLoginButton component

    import { GoogleLoginButton } from "delta-react-google-authentication";
    
    const Login = () => {
      return (
        <GoogleLoginButton
          backendUrl="http://localhost:5000"
          buttonText="Sign in with Google"
        />
      );
    };
    
    export default Login;

    2️⃣ Use useGoogleAuth Hook to Get User Data

    import { useGoogleAuth } from "delta-react-google-authentication";
    
    const Dashboard = () => {
      const { user, loading } = useGoogleAuth(backendUrl);
    
      return (
        <div>
          {user ? (
            <div>
              <h2>Welcome, {user.name} 👋</h2>
              <img src={user.profilePic} alt="Profile" />
              <p>Email: {user.email}</p>
            </div>
          ) : (
            <p>User not logged in</p>
          )}
        </div>
      );
    };
    
    export default Dashboard;

    🔹 Logout

    To log out the user, call:

    import { useGoogleAuth } from "delta-react-google-authentication";
    const Logout = () => {
      const {logout } = useGoogleAuth(backendUrl);
        return (
    <button onClick={logout}>Logout</button>;
    )};
    
    export default Logout;

    🔐 Token

    Token will be saved in localStorage as authToken.

    📜 License

    This project is licensed under the MIT License.

    💻 Contributing

    Feel free to submit issues and pull requests on GitHub.


    Happy coding! 🚀