🚀 My Hilariously Chaotic Quest to Build a Custom Hive Login React UI Plugin 😅

Hello Hive community members

So, after wrestling with @aioha's react-ui and achieving little more than existential dread, I bravely (read: foolishly) decided to code my own solution from scratch. Who needs sleep anyway, right?

Check out my previous disaster—I mean, post—about my misadventures with keychain SDK integration in React:

Last Episode: React Keychain SDK Facepalms

Trying to integrate HiveAuth in react-js-app? Challenge accepted... and instantly regretted.

npm install hive-auth-wrapper

Spoiler alert: Not compatible with react-js. Buffer errors everywhere! (I skipped documenting the headaches, but you can recreate my misery with a fresh react-js project.)

headache meme

In summary—Both HiveKeychain & HiveAuth:
🧠 ➡️ 🤯

Suddenly, “Why am I doing this to myself?” became my new mantra.

retreat meme


🏃‍♂️ Rolling Back Like a Pro (or Not) 🏃‍♂️

Taking two steps forward, three steps back: the true dev way!
Time to:

  • Uninstall keychain-sdk & hive-auth-wrapper
  • Reinstall aioha-core & aioha-react-provider
  • Regret nothing!!! (okay, maybe a little)

Say goodbye to global & module polyfills:

npm uninstall @esbuild-plugins/node-globals-polyfill
npm uninstall @esbuild-plugins/node-modules-polyfill

Hello to vite polyfills:

npm i vite-plugin-node-polyfills

Out with the old experiments:

npm uninstall buffer hive-auth-wrapper keychain-sdk

In with the new (again):

npm i @aioha/aioha
npm i @aioha/react-provider @aioha/aioha

All set! Time for the next round of updates—to infinity, and… more config files!


⚙️ Setting Up Aioha With Provider… Again 🙃

again

import { initAioha } from "@aioha/aioha";
import { AiohaProvider } from "@aioha/react-provider";
import { useUserTokenStore } from "@/store/UserTokenStore";

// variables
const aioha = initAioha({
  hiveauth: {
    name: "Hive Login React",
    description: "Login with Hive React Component",
  },
});

const HiveLoginButton = () => {
  return (
    <AiohaProvider aioha={aioha}>
      {userTokenStore.apiState === "loading"
        ? loader()
        : userTokenStore.user() !== null
        ? userAvatarBasedButton()
        : loginButton()}
      <HiveLoginModal />
    </AiohaProvider>
  );
}

🔍 Keychain Logic Gets an Upgrade (Like, Finally!) 🧐

  useEffect(() => {
    const check = async () => {
      console.log("We don't have keychain yet");
      await new Promise((res) => setTimeout(res, 500));
      const isKeychainInstalled = aioha.isProviderEnabled(Providers.Keychain);
      console.log(
        `Do we have keychain now? ${isKeychainInstalled ? "yes" : "no"}`
      );
      setKeychainAvailable(isKeychainInstalled);
    };

    if (document.readyState === "complete") {
      check();
    } else {
      window.addEventListener("load", check);
      return () => window.removeEventListener("load", check);
    }
  }, []);

When Users Tap “Login with Keychain” 🗝️

  const onKeychainLoginTapped = async () => {
    try {
      const newProof = new Date().toISOString();
      setProof(newProof);
      const loginResult = await aioha.login(Providers.Keychain, username, {
        msg: newProof,
        keyType: KeyTypes.Posting,
        loginTitle: "Login",
      });

      if (loginResult.success) {
        const user = await userTokenStore.login(loginResult, newProof);
        console.log(`Logged in user is ${JSON.stringify(user)}`);
        if (dialogRef.current) {
          dialogRef.current.close();
        }
      } else {
        console.log("Something went wrong");
      }
    } catch (error) {
      console.log({ error });
    }
  };

🧸 Reinventing State Management (Bye Redux, Hi Zustand Bear!) 🎉

Installing zustand was the best decision since breakfast:

npm i zustand

zustand

zustand implementation screenshot with code

Now state management is so easy, I almost feel clever again! 🐻


🚧 What’s Next on My Hive React Adventure? 🎯

  • What if the same user tries to login again? Time to handle edge cases!
  • Craft a “Switch User” screen for seamless logins.
  • Package everything into a neat library (eventually).
  • Enable encryption key & API URL customization for devs.
  • More memes, more caffeine, more Hive.

🟢 More Power To Hive (And To Bearing My Meme-Fueled Struggles!)

  • Big shoutout to open-source warriors at keychain, hiveauth, aioha 💪
  • Hive community—y’all are amazing!
  • Hive blockchain to the moon… and BEYOND! 🚀🌕✨

infinity & beyond


Thanks for surviving this post! Send help (and coffee) as I continue this Hive React UI plugin journey.


📝 Final Note


🚀 My Contributions to ♦️ Hive Ecosystem

ContributionToHiveEcosystem
Hive Witness NodeHive API Node (in progress)3Speak Video Encoder Node Operator (highest number of nodes)3Speak Mobile App Developer
3Speak Podcast App Developer3Speak Shorts App Developer3Speak Support & Maintenance TeamDistriator Developer
CheckinWithXYZHive InboxHiFindHive Donate App
Contributed to HiveAuth Mobile AppEcency ↔ 3Speak IntegrationEcency ↔ InLeo IntegrationEcency ↔ Actifit Integration
Hive Stats AppVote for Witness AppHiveFlutterKitNew 3Speak App

🙌 Support Back

❤️ Appreciate my work? Consider supporting @threespeak & @sagarkothari88! ❤️

VoteForWitness
sagarkothari88@sagarkothari88
threespeak@threespeak



0
0
0.000
7 comments
avatar

This post has been manually curated by @bhattg from Indiaunited community. Join us on our Discord Server.

Do you know that you can earn a passive income by delegating to @indiaunited. We share more than 100 % of the curation rewards with the delegators in the form of IUC tokens. HP delegators and IUC token holders also get upto 20% additional vote weight.

Here are some handy links for delegations: 100HP, 250HP, 500HP, 1000HP.

image.png

100% of the rewards from this comment goes to the curator for their manual curation efforts. Please encourage the curator @bhattg by upvoting this comment and support the community by voting the posts made by @indiaunited..

This post received an extra 7.51% vote for delegating HP / holding IUC tokens.

0
0
0.000
avatar

We had an interview with stoodkev about some of this on the Hive Thrive show... sadly, as of right now, we have to build "our own login/wallets" if we want things to work seamlessly.

At least you are getting a masterclass on this specific subject at the moment.

0
0
0.000
avatar

Thank you @meno

It's all open source as stated in the post.

Once the fruit is ripe, you can take all you want.

it's yours

0
0
0.000