## πŸ‘‹ Hello, Hive Community! Welcome fellow #Hivers! As I dove into the magical world of Hive Keychain SDK integration, I hit a few snags (and had some laughs along the way). So here's my entertaining, step-by-step breakdown for getting it working smoothly in your own React project (using React + Vite + Typescript + Tailwind CSS + DaisyUI). Grab a chai, let's go! β˜• --- ### πŸ“š **Step 1: Getting the Tools** First, head to the mystical land of: - πŸ”— [hive-keychain.com](https://hive-keychain.com) - Find the **Resources** menu - Summon the "Keychain SDK" ![Open Hive-keychain.com](https://files.peakd.com/file/peakd-hive/sagarkothari88/23tw5bBNweJUprcGmt7Tfj6xLhGJjvLgwYm29xcnHwKQAdwtDarfsRDKQiJuJLvV5Awjv.png) --- ### πŸ› οΈ **Step 2: Install Stuff Because RTFM Is Life** - In terminal, cast this spell: `npm install keychain-sdk` - Import the SDK like a proper developer: ``` import { KeychainSDK } from "keychain-sdk"; ``` - Create your wizard: ``` const keychain = new KeychainSDK(window); ``` ![npm install](https://files.peakd.com/file/peakd-hive/sagarkothari88/Eo8ZZNvKB66NYqFY9Xud2VwyzDTzFA8P1cae55CmRFzbWDGhDcYUsMi6oi1eKq22n8N.png) --- ### πŸ’₯ **Step 3: Reality Hits - Error Galore!** Ran `npm run dev` to behold my genius at `localhost:5173`… but NOPE. Got smacked by a mysterious browser error. ![Browser buffer errors](https://files.peakd.com/file/peakd-hive/sagarkothari88/23tSKZeEFddLJjBagAYnEVzFQ3st1n8GC3iR1t5oHBksj6hnMkPn12Tp7ThyJyzpiFnS6.png) --- ### πŸ€– **Step 4: Summon the AI Overlords** - AI said: "Install buffer, foolish mortal!" - So, I blindly did: `npm install buffer` - *Result? Still borked.* ![install buffer](https://files.peakd.com/file/peakd-hive/sagarkothari88/23t74taBUT9afpF7dPJQHWQPtqucpmkjoARqigaMuWmRv5W44MBrrhBrHAAsejYqFELNT.png) --- ### πŸ§™β€β™‚οΈ **Step 5: The Sorcerer’s Config** Next, AI bestowed arcane knowledge. I bent the knee to update my `vite.config.ts`: ![confusion configs meme](https://media.tenor.com/TzDm4XWWzqwAAAAC/question-mark.gif) ``` import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import tailwindcss from "@tailwindcss/vite"; import { NodeGlobalsPolyfillPlugin } from "@esbuild-plugins/node-globals-polyfill"; import { NodeModulesPolyfillPlugin } from "@esbuild-plugins/node-modules-polyfill"; export default defineConfig({ plugins: [react(), tailwindcss()], optimizeDeps: { esbuildOptions: { define: { global: "globalThis", }, plugins: [ NodeGlobalsPolyfillPlugin({ buffer: true, process: true, }), NodeModulesPolyfillPlugin(), ], }, }, resolve: { alias: { buffer: "buffer", }, }, }); ``` --- ### ⚑ **Step 6: (Re)Try Everything!** With the config in place, I bravely ran `npm run dev`. 🧘 *No errors. Hope returns!* Time for the next spell: **Check if Hive Keychain is present:** ``` import { KeychainSDK } from "keychain-sdk"; import { useEffect, useState } from "react"; const HiveLoginModal = () => { const keychain = new KeychainSDK(window); const [keychainAvailable, setKeychainAvailable] = useState(false); useEffect(() => { const check = async () => { const isKeychainInstalled = await keychain.isKeychainInstalled(); console.log(`Do we have keychain now? ${isKeychainInstalled ? 'yes': 'no'}`); setKeychainAvailable(isKeychainInstalled); }; check(); }, []); ``` **BUT... it logged 'no' even with Hive Keychain installed!** πŸ€” What dark magic is this? ![confusion meme](https://media.tenor.com/Kbqu5uTE6oIAAAAC/why-monkey.gif) --- ### 🀯 **Step 7: Ask AI Again (Yep, Again)** ![AI Conversation screenshot](https://files.peakd.com/file/peakd-hive/sagarkothari88/23tGVTsMXi4ZGZpEt6XtAd5HGnMSBRxQUXEE2jFuHD6X4ZgGabjB5UNF8ESpY1Dupy3gM.png) **AI says:** β€œDelay just a bit - Keychain needs time to show up!” So here's the new check: ``` useEffect(() => { const check = async () => { console.log("We don't have keychain yet"); await new Promise((res) => setTimeout(res, 500)); const keychain = new KeychainSDK(window); const isKeychainInstalled = await keychain.isKeychainInstalled(); 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); } }, []); ``` **BOOM!** After this, it *finally* worked. Friends, I am just getting started. More guides on the way. Hive-Keychain SDK team should totally add a React-focused pageβ€”imagine the memes! πŸ˜‚ --- ## πŸ™ **Final Words and Power-Ups** - More power to Hive-keychain dev team! πŸ‘¨β€πŸ’»πŸš€ - More power to Hive community members! 🀝 - More power to Hive blockchain! πŸ”— - More power to Hive! πŸ’₯ - Hive to the moon and beyond! πŸŒ• ![Hive to the moon and beyond](https://media.tenor.com/l-p7XLsKJsoAAAAC/to-infinity-and-beyond-buzz-lightyear.gif) --- ### πŸ“ 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/3d96d12b-d8ca-419f-92a6-093569aa96b1 --- ### πŸš€ My Contributions to ♦️ Hive Ecosystem | Contribution | To | Hive | Ecosystem | |--------------|----|------|-----------| | Hive Witness Node | Hive API Node (in progress) | 3Speak Video Encoder Node Operator (highest number of nodes) | 3Speak Mobile App Developer | | 3Speak Podcast App Developer | 3Speak Shorts App Developer | 3Speak Support & Maintenance Team | [Distriator Developer](https://distriator.com/) | | [CheckinWithXYZ](https://checkinwith.xyz/) | [Hive Inbox](https://hive-inbox.the-hive-mobile.app/) | [HiFind](https://hifind.the-hive-mobile.app/) | [Hive Donate App](https://donate.the-hive-mobile.app/) | | Contributed to HiveAuth Mobile App | Ecency ↔ 3Speak Integration | Ecency ↔ InLeo Integration | Ecency ↔ Actifit Integration | | [Hive Stats App](https://stats.the-hive-mobile.app/) | [Vote for Witness App](https://witness.the-hive-mobile.app/) | [HiveFlutterKit](https://hiveflutterkit.sagarkothari88.one/docs/intro) | [New 3Speak App](https://3speak.sagarkothari88.one/#/?tab=home) | --- ### πŸ™Œ Support Back ❀️ **Appreciate my work? Consider supporting @threespeak & @sagarkothari88!** ❀️ | Vote | For | Witness | |------|-----|---------| | [![](https://images.hive.blog/u/sagarkothari88/avatar)](https://witness.the-hive-mobile.app/#/witnesses/@sagarkothari88) | [sagarkothari88](https://witness.the-hive-mobile.app/#/witnesses/@sagarkothari88) | @sagarkothari88 | | [![](https://images.hive.blog/u/threespeak/avatar)](https://witness.the-hive-mobile.app/#/witnesses/@threespeak) | [threespeak](https://witness.the-hive-mobile.app/#/witnesses/@threespeak) | @threespeak | ---