@beaconmcu/auth 0.1.0 → 0.1.1

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.
Files changed (2) hide show
  1. package/README.md +31 -1
  2. package/package.json +12 -1
package/README.md CHANGED
@@ -8,7 +8,9 @@ Add "Sign in with Google" to your Stellar dApp. Your users get a wallet instantl
8
8
  npm install @beaconmcu/auth
9
9
  ```
10
10
 
11
- Create an app in the [Beacon dashboard](https://dashboard.beaconmcu.space), add your site's URL as an allowed origin, and copy the Client ID.
11
+ Create an app in the [Beacon dashboard](https://dashboard.beaconmcu.space) and copy its Client ID. Local development (`localhost`) works with nothing else to set up; add your live site's address under **Domains** before you launch.
12
+
13
+ **Requirements:** a modern browser. The package has no dependencies, includes TypeScript types, and works as ESM or CommonJS. Full docs: https://dashboard.beaconmcu.space/docs
12
14
 
13
15
  ## Quick start
14
16
 
@@ -26,6 +28,34 @@ await beacon.logout();
26
28
 
27
29
  `beacon.getAddress()` returns the address or `null`. `beacon.getNetwork()` returns the active network.
28
30
 
31
+ ## React and Next.js
32
+
33
+ Create one `BeaconAuth` for the whole app, in its own file, and read it from your components:
34
+
35
+ ```tsx
36
+ // beacon.ts
37
+ import { BeaconAuth } from "@beaconmcu/auth";
38
+ export const beacon = new BeaconAuth({ clientId: "bcn_app_...", defaultNetwork: "testnet" });
39
+
40
+ // LoginButton.tsx (in Next.js, add "use client" at the top)
41
+ import { useEffect, useState } from "react";
42
+ import { beacon } from "./beacon";
43
+
44
+ export function LoginButton() {
45
+ const [address, setAddress] = useState(beacon.getAddress());
46
+
47
+ useEffect(() => beacon.on("accountChanged", setAddress), []); // returns the function that unsubscribes
48
+
49
+ return address ? (
50
+ <button onClick={() => beacon.logout()}>Log out ({address.slice(0, 6)}…)</button>
51
+ ) : (
52
+ <button onClick={() => beacon.login()}>Log in</button>
53
+ );
54
+ }
55
+ ```
56
+
57
+ It is safe to import on the server (it only touches the page in the browser). Use it from client-side code.
58
+
29
59
  ## Send XLM (one call)
30
60
 
31
61
  ```ts
package/package.json CHANGED
@@ -1,7 +1,18 @@
1
1
  {
2
2
  "name": "@beaconmcu/auth",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Embedded wallet with Google sign-in for Stellar dApps",
5
+ "keywords": [
6
+ "stellar",
7
+ "soroban",
8
+ "wallet",
9
+ "embedded-wallet",
10
+ "google-login",
11
+ "social-login",
12
+ "web3",
13
+ "auth"
14
+ ],
15
+ "homepage": "https://dashboard.beaconmcu.space/docs",
5
16
  "license": "MIT",
6
17
  "type": "module",
7
18
  "main": "./dist/index.cjs",