π§βπ» Hive dApps & dPackages development - hive-authentication package π¦ usage guide π
π Whatβs the Buzz About?
Hello Hive community members! π
- You may have seen me mention the
hive-authenticationpackage in earlier posts, but never with this much jazz. - Thatβs because it was, well, marinating like a fine curry. π
- But nowβitβs piping hot and ready for YOU to spice up your projects!
- No more waiting! Time to fire it up in your ReactJS apps. π
β οΈ Quick Note:
This is strictly for ReactJS projects! No plain vanilla, no Angular, no Vueβjust pure ReactJS flavor.
π Where To Find It?
π€ Why Use hive-authentication?
- Need to verify proof-challenge signed by a hive user from your backend? β
- Want to let users login with a private posting key (as the last resort)? β
- Fancy custom local storage per user? β
- Donβt need any of this? No worriesβstick to @aioha and party on! π
Now you know the βwhyββletβs jump in!
π οΈ How to Implement in ReactJS
Step 1: Install
npm install hive-authentication
Step 2: Initialize in App.tsx
Open up App.tsx and set up your authentication flow! π₯
import { initAioha } from '@aioha/aioha'
import { AiohaProvider } from '@aioha/react-provider'
const aioha = initAioha(
{
hivesigner: {
app: 'hive-auth-demo.app',
callbackURL: window.location.origin + '/hivesigner.html',
scope: ['login', 'vote']
},
hiveauth: {
name: 'Hive Authentication Demo',
description: 'A demo app for testing Hive authentication'
}
}
)
function App() {
return (
<AiohaProvider aioha={aioha}>
<div>Your App goes here</div>
</AiohaProvider>
);
}
Step 3: Add the Magic AuthButton
import { AuthButton, useAuthStore } from 'hive-authentication';
import 'hive-authentication/build.css';
import { useAioha } from "@aioha/react-provider";
function YourComponent() {
const { currentUser, loggedInUsers } = useAuthStore();
const { aioha } = useAioha();
useEffect(() => {
const unsubscribe = useAuthStore.subscribe((state) => {
console.log('Store state changed:', state);
});
return unsubscribe;
}, []);
return (
<div>
<h1>My App</h1>
<AuthButton
onAuthenticate={handleAuthenticate}
aioha={aioha}
shouldShowSwitchUser = {true} // Optional true
onClose={() => {
console.log("AuthButton dialog closed");
}}
/>
{currentUser && (
<p>Welcome, {currentUser.username}!</p>
)}
</div>
);
}
Step 4: Call Your Backend Like a Pro
const handleAuthenticate = async (hiveResult: HiveAuthResult): Promise<string> => {
console.log('Hive authentication result:', hiveResult);
try {
const response = await fetch("https://beta-api.distriator.com/login", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
challenge: hiveResult.challenge,
username: hiveResult.username,
pubkey: hiveResult.publicKey,
proof: hiveResult.proof,
}),
});
if (!response.ok) {
throw new Error(`Server authentication failed: ${response.status} ${response.statusText}`);
}
const data = await response.json();
console.log('Server response:', data);
// Return your server response as JSON string
return JSON.stringify(data);
} catch (error) {
console.error("Authentication error:", error);
throw error;
}
};
Wait for the useEffect state change messageβvoila, it works!
π Done & Dusted
Yep, thatβs pretty much it. Easy as pie. π₯§
Give it a spin and let me know how it powers up your Hive projects!
π¦Ύ More Power to Hive (and You!)
- More power to Hive community members!
- More power to open-source contributors!
- More power to Hive blockchain!
- Hive to the moon and beyond ππ
π Support & Love
- Tried this package? Drop your feedback in the comments! π¬
- Liked my work? Upvote this post! π
- Want to keep seeing new stuff? Vote me as Hive Witness π
- Love me? Tip me on this post!
- See you in the next updateβBYE BYE! π
π Final Note
- I asked perplexity to help optimize this post to make it more readable and viewer-friendly.
- Here is the link where you can find both original content & improvements made by AI
- https://www.perplexity.ai/search/9b9e4552-5b5e-43ff-8a76-53cbf691132a
π My Contributions to β¦οΈ Hive Ecosystem
| Contribution | To | Hive | Ecosystem |
|---|---|---|---|
| Hive Witness Node | Hive API Node | 3Speak Video Encoder Node Operator (highest number of nodes) | 3Speak Mobile App Developer |
| Podcast App Developer | 3Shorts App Developer | 3Speak Support & Maintenance Team | Distriator Developer |
| CheckinWithXYZ | Hive Inbox | HiFind | Hive Donate App |
| Contributed to HiveAuth Mobile App | Ecency β 3Speak Integration | Ecency β InLeo Integration | Ecency β Actifit Integration |
| Hive Stats App | Vote for Witness App | HiveFlutterKit | New 3Speak App |
π Support Back
β€οΈ Appreciate my work? Consider supporting &
! β€οΈ
| Vote | For | Witness |
|---|---|---|
| sagarkothari88 | ||
| threespeak |
Leave π§βπ» Hive dApps & dPackages development - hive-authentication package π¦ usage guide π to:
Read more #hive posts
Best Posts From Sagar Kothari
We have not curated any of sagarkothari88's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From Sagar Kothari
- HiveReactKit v1.2.5: Scroll Restoration Magic β¨ #opensource #hive
- HiveSuite Can Now Publish to ANY Hive App π #opensource #hive
- Re-Snaps, Smarter Replies & Bulletproof Node Routing π #hive #opensource
- HiveReactKit Now Plays 3Speak Audio + Smarter Nodes π§ #opensource #hive
- Re-Snaps, Meme Maker & Twitter Embeds Land in HiveSuite π #opensource #hive
- HiveSuite Never Goes Down Now π Smart API Failover #opensource #hive
- HiveSuite Adds Inline Replies & Rich Notifications β‘ #opensource #hive
- HiveSuite Adds Inline Replies & Rich Notifications β‘ #opensource #hive
- HiveSuite Adds Inline Maps, Custom Nodes & Big UX Wins πΊοΈ #opensource #hive
- HiveSuite Update: Polls, Delegations & Smarter Notifications β‘ #hive #opensource
- HiveSuite Dev Update: Massive Design System Glow-Up π¨π
- HiveReactKit Dev Update: Post Experience Refinements, Rewards Redesign & WorldMappin Integration
- HiveReactKit Dev Update: Composer, Wallet, Polls & Snaps Improvement
- HiveReactKit Dev Update - 24-Jun-2026
- HiveSuite Dev Update: Tank Strike Joins the Games Collection
- HiveSuite Dev Update: Wallet Actions Broadcasting & Reward Claim Integration
- HiveReactKit Dev Update: Pending Rewards, Reliable Pagination & Wallet
- HiveReactKit Dev Update: Expanded Wallet Actions & Improved Balance Mgmt
- HiveSuite Dev Update: Governance Dashboard & In-App Profile Editing
- HiveSuite Dev Updates: Location-Aware Posts, Colored Code Blocks & In-App Changelog