login-signup-google 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +13 -0
- package/src/GoogleLogin.jsx +26 -0
- package/src/Login.jsx +12 -0
- package/src/Signup.jsx +12 -0
- package/src/index.js +4 -0
package/package.json
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "login-signup-google",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Reusable React Login, Signup and Google Login components",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"keywords": ["react", "login", "signup", "google-auth"],
|
|
7
|
+
"author": "Your Name",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
|
|
10
|
+
"peerDependencies": {
|
|
11
|
+
"react": ">=18"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
// src/GoogleLogin.jsx
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
|
|
4
|
+
export default function GoogleLogin({ clientId, onSuccess }) {
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const script = document.createElement("script");
|
|
7
|
+
script.src = "https://accounts.google.com/gsi/client";
|
|
8
|
+
script.async = true;
|
|
9
|
+
script.defer = true;
|
|
10
|
+
document.body.appendChild(script);
|
|
11
|
+
|
|
12
|
+
script.onload = () => {
|
|
13
|
+
window.google.accounts.id.initialize({
|
|
14
|
+
client_id: clientId,
|
|
15
|
+
callback: onSuccess,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
window.google.accounts.id.renderButton(
|
|
19
|
+
document.getElementById("googleBtn"),
|
|
20
|
+
{ theme: "outline", size: "large" }
|
|
21
|
+
);
|
|
22
|
+
};
|
|
23
|
+
}, [clientId, onSuccess]);
|
|
24
|
+
|
|
25
|
+
return <div id="googleBtn"></div>;
|
|
26
|
+
}
|
package/src/Login.jsx
ADDED
package/src/Signup.jsx
ADDED
package/src/index.js
ADDED