## π οΈ From NavBar Mess to React Router Success! π Hello **Hive Community** π, - [π Day before yesterday](https://peakd.com/hive-139531/@sagarkothari88/integrate-aioha-with-your-react-app-from-scratch-vite--tailwind--daisyui), we built a fresh React app and integrated AIOHA. - [π§ Yesterday](https://peakd.com/hive-139531/@sagarkothari88/integrating-react-router-my-routing-adventures-with-react), we explored routing... but yeah, our NavBar decided to rebel. π€ --- ## π― Todayβs Mission (Impossible?) 1. Fix the broken NavBar π΅ 2. Integrate navigation using `react-router-dom`βs `<Link>` 3. Create a *layout* to avoid repeating NavBar on every page --- ### πͺ Fixing the NavBar Bug  See this monstrosity above? π± Thatβs what we got even though we copied the beautiful DaisyUI navbar. π€ After a LOT of head-scratching and a few cups of chai β...  Boom! Found it β I forgot to import `daisyui` in `app.css` π€¦ **One small import for me, one giant leap for NavBar!** --- ### π§© Updated NavBar Component ```jsx import React from "react"; import HiveUserAvatarButton from "./HiveUserAvatarButton"; const NavBar = () => { return ( <div className="navbar bg-base-100 shadow-sm"> <div className="flex-1"> <a className="btn btn-ghost text-xl">Distriator</a> </div> <div className="flex-none"> <HiveUserAvatarButton /> </div> </div> ); }; export default NavBar; ``` > Notice weβre using a fancy new `HiveUserAvatarButton` component π --- ### π§βπ Custom AIOHA Login Button  Time to ditch that boring default button. Letβs use our custom-built login avatar button that: - Shows a **Login** button if user is not logged in - Displays **avatar** if logged in β ```jsx import { useState } from "react"; import { useAioha, AiohaModal } from "@aioha/react-ui"; import { KeyTypes } from "@aioha/aioha"; import "@aioha/react-ui/dist/build.css"; const HiveUserAvatarButton = () => { const [modalDisplayed, setModalDisplayed] = useState(false); const { user } = useAioha(); function userAvatarBasedButton() { return ( <div className="avatar" onClick={() => setModalDisplayed(true)}> <div className="w-10 rounded-full overflow-hidden"> <img src={`https://images.hive.blog/u/${user}/avatar`} /> </div> </div> ); } function loginButton() { return (<button className="btn btn-primary" onClick={() => setModalDisplayed(true)}>Login</button>); } function aiohaModel() { return ( <div> <AiohaModal displayed={modalDisplayed} loginOptions={{ msg: "Login", keyType: KeyTypes.Posting, }} onLogin={console.log} onClose={setModalDisplayed} /> </div> ); } return ( <> {user ? userAvatarBasedButton() : loginButton()} {aiohaModel()} </> ); }; export default HiveUserAvatarButton; ``` --- ## π§± Letβs Build a Common Layout Because... DRY (Donβt Repeat Yourself) π ```jsx import React from 'react' import NavBar from './NavBar' const CommonLayout = ({children}) => { return ( <> <div> <NavBar /> </div> <main>{children}</main> </> ); } export default CommonLayout; ``` > π Now every page can reuse this layout with the NavBar already baked in. --- ### π Using the Common Layout on a Page ```jsx import React from 'react' import CommonLayout from '../../Components/CommonLayout' const AboutUsPage = () => { return ( <CommonLayout> <div>AboutUsPage</div> </CommonLayout> ) } export default AboutUsPage; ``` --- ## π§ Add Nav Links for Navigation Time to give our NavBar a promotion by adding **About Us** & **Contact Us** links!  Thank you DaisyUI for making this super easy. Just βοΈ copy & paste...  --- ## π Use React Routerβs `<Link>` β No More `<a>`  Replace all old-school `<a href>` with `<Link to>` from `react-router-dom` β That way, no page refreshes and smooth routing FTW β‘ --- ## π§βπ» Final Words Todayβs work may look small but helped build strong foundation for the app. - β NavBar fixed - β AIOHA integrated smartly - β Routing UX improved - β Codebase looks cleaner Thanks for following along! See you in the next post π --- **Happy Building! π»β€οΈ** --- ### π Final Note - I asked ChatGPT/AI 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://chatgpt.com/share/688771b9-0c28-8000-aef5-24976fe84278 --- ### π 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://witness.the-hive-mobile.app/#/witnesses/@sagarkothari88) | [sagarkothari88](https://witness.the-hive-mobile.app/#/witnesses/@sagarkothari88) | @sagarkothari88 | | [](https://witness.the-hive-mobile.app/#/witnesses/@threespeak) | [threespeak](https://witness.the-hive-mobile.app/#/witnesses/@threespeak) | @threespeak | ---
author | sagarkothari88 |
---|---|
permlink | from-navbar-mess-to-react-router-success-fixing-layouts-routing-and-aioha-in-one-go |
category | hive-139531 |
json_metadata | "{"app":"peakd/2025.7.3","format":"markdown","description":"Fixed ui-navbar issues, added layout & integrated react-router with AIOHA login for a seamless UX Debugging included πΉ","tags":["hive","development","webapp","reactjs","reactrouter","javascript","frontend","aioha","webdev","opensource"],"users":["sagarkothari88","aioha","threespeak"],"image":["https://files.peakd.com/file/peakd-hive/sagarkothari88/23t84fBJnhHbWnCfya6nxJh9zHd4NMiBkw97D1MszjncZ6r5RkUUd1wGwmULReru1eCyZ.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/23tGZrHMcMCrBoSeoqPHumYHFTAbocL5ie9piAJPvMWEhgAjpnHXeGSuwX313p4HtHijm.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/EoGpiNib6in7UWVXVHSdYdXqjnaXyNY6JA7fTQVdXt1dn3H5SJbmGsDtJmiN2nCrirb.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/23tGXZByKwCtXgcMfSxMoATLjpDCyYy21degWVtQqGhpMPYyaj2pNETr82ibpzVN9H7ub.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/23t74ySHw58E3P7LKNGHf68od5SpQpkyYunWo4DJRJZiG7zXtkMkeybGdhtRhiwJk3CUS.png","https://files.peakd.com/file/peakd-hive/sagarkothari88/23tGZmVSmhE4gC9L71vnoP2x2TVYZrV8HDLoU8a8stbZYnYtbaRzb6wYQHV4ePYDzbZyK.png","https://images.hive.blog/u/sagarkothari88/avatar","https://images.hive.blog/u/threespeak/avatar"]}" |
created | 2025-07-29 04:30:00 |
last_update | 2025-07-29 04:30:00 |
depth | 0 |
children | 0 |
last_payout | 1969-12-31 23:59:59 |
cashout_time | 2025-08-05 04:30:00 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 14.127 HBD |
promoted | 0.000 HBD |
body_length | 7,137 |
author_reputation | 545,807,411,358,302 |
root_title | "From NavBar Mess to React Router Success! Fixing Layouts, Routing & AIOHA in One Go π" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 144,500,479 |
net_rshares | 44,908,276,656,525 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
ardina | 0 | 31,171,613,293 | 100% | ||
penguinpablo | 0 | 142,697,394,633 | 14% | ||
funnyman | 0 | 1,462,145,385 | 5.6% | ||
gamer00 | 0 | 19,722,278,953 | 5% | ||
ambyr00 | 0 | 637,492,895 | 0.75% | ||
humoalex | 0 | 512,162,169 | 30% | ||
thecrazygm | 0 | 71,012,837,285 | 100% | ||
josequintana | 0 | 1,243,282,167 | 30% | ||
nenio | 0 | 101,201,514,355 | 25% | ||
alphacore | 0 | 7,212,365,860 | 7.12% | ||
joeyarnoldvn | 0 | 449,452,676 | 1.47% | ||
vikbuddy | 0 | 24,044,711,367 | 31% | ||
vimukthi | 0 | 560,168,792 | 10% | ||
ahlawat | 0 | 51,024,182,717 | 100% | ||
aafeng | 0 | 225,983,722,099 | 25% | ||
noloafing | 0 | 3,024,085,511 | 49.76% | ||
sneakyninja | 0 | 17,020,932,649 | 24.88% | ||
steembasicincome | 0 | 1,657,288,937,368 | 100% | ||
cryptonized | 0 | 235,693,536 | 14% | ||
deepresearch | 0 | 708,564,127,839 | 18% | ||
irisworld | 0 | 1,115,550,375 | 7.5% | ||
anikys3reasure | 0 | 1,153,985,347 | 50% | ||
abrockman | 0 | 2,712,467,938,201 | 100% | ||
louis88 | 0 | 1,377,485,552,688 | 50% | ||
sbi2 | 0 | 1,101,393,587,406 | 100% | ||
knot | 0 | 42,057,994,568 | 50% | ||
sbi3 | 0 | 558,504,344,799 | 100% | ||
sbi4 | 0 | 374,680,002,239 | 100% | ||
netzisde | 0 | 3,367,249,453 | 100% | ||
techcoderx | 0 | 1,031,113,636,112 | 100% | ||
kolkamkwan | 0 | 77,293,885,150 | 100% | ||
frieder | 0 | 1,577,148,294 | 50% | ||
bububoomt | 0 | 5,339,855,486 | 100% | ||
sbi5 | 0 | 300,518,242,247 | 100% | ||
sbi6 | 0 | 233,713,224,859 | 100% | ||
thedailysneak | 0 | 23,292,891,644 | 24.88% | ||
smartvote | 0 | 219,482,147,587 | 10% | ||
sbi7 | 0 | 175,115,238,052 | 100% | ||
thelittlebank | 0 | 969,422,706,585 | 50% | ||
nareebun | 0 | 6,265,530,697 | 50% | ||
piensocrates | 0 | 480,996,575 | 30% | ||
ecoinstats | 0 | 228,558,933,499 | 100% | ||
sbi8 | 0 | 127,760,601,567 | 100% | ||
piestrikesback | 0 | 642,075,264 | 100% | ||
sbi9 | 0 | 93,384,604,836 | 100% | ||
buildingpies | 0 | 51,763,714,624 | 100% | ||
sbi10 | 0 | 70,734,336,806 | 100% | ||
jacuzzi | 0 | 669,625,049 | 1.4% | ||
hungrybear | 0 | 622,303,337 | 14% | ||
coolmole | 0 | 44,540,010,797 | 50% | ||
russia-btc | 0 | 221,119,485,940 | 70% | ||
sbi-tokens | 0 | 20,599,949,299 | 49.76% | ||
urun | 0 | 7,778,464,057 | 100% | ||
bilpcoin.pay | 0 | 548,431,865 | 10% | ||
qwertm | 0 | 3,874,025,652 | 50% | ||
treasure.hoard | 0 | 386,796,513,611 | 100% | ||
tht | 0 | 12,162,166,096 | 100% | ||
ykretz | 0 | 1,378,371,865 | 15% | ||
kiemis | 0 | 8,790,470,074 | 2.5% | ||
balvinder294 | 0 | 7,969,070,534 | 30% | ||
archon-gov | 0 | 95,606,341,709 | 50% | ||
cocaaladioxine | 0 | 18,281,314,651 | 97% | ||
szukamnemo | 0 | 28,361,641,875 | 9% | ||
emsenn0 | 0 | 1,995,780,296 | 9.95% | ||
azamrai | 0 | 567,462,209,387 | 100% | ||
kkingg | 0 | 990,018,864 | 50% | ||
louis.pay | 0 | 498,678,291 | 50% | ||
hive.friends | 0 | 871,866,217 | 50% | ||
nongkamsailucky | 0 | 5,028,777,554 | 100% | ||
nastapak | 0 | 779,876,859 | 50% | ||
tub3r0 | 0 | 737,902,164 | 10% | ||
techguard | 0 | 554,488,830 | 9% | ||
djblendah | 0 | 891,777,172 | 100% | ||
ryosai | 0 | 5,860,903,361 | 24% | ||
veryhappyday | 0 | 243,162,763,828 | 100% | ||
incublus | 0 | 144,187,720,857 | 50% | ||
tekraze | 0 | 1,694,690,410 | 60% | ||
threespeakvoter | 0 | 16,598,075,845,544 | 100% | ||
hive.samadi | 0 | 9,878,258,369 | 100% | ||
luchyl | 0 | 18,104,296,736 | 39% | ||
briefmarken | 0 | 44,344,140,514 | 100% | ||
lovver | 0 | 1,246,416,697 | 100% | ||
somecallmejake | 0 | 13,518,680,184,618 | 100% | ||
joseph2014 | 0 | 7,177,356,536 | 100% | ||
michael561 | 0 | 2,706,559,802 | 9.95% | ||
hivekr | 0 | 20,492,880,699 | 100% |