🧭 Integrating React Router: My Routing Adventures with React 🛣️

in HiveDevs6 days ago

🧭 Integrating React Router: My Routing Adventures with React 🛣️

Yesterday, we summoned Aioha into a fresh React app. Today, we open the portals of navigation! 🌀


👋 Hello Hive Community

Yesterday, we learned how to create a brand-new React project from scratch & integrated Aioha into it. Today, let's level up our frontend skills with routing.

Because let’s face it—every React app needs to know where to go! 🧭


🛠️ Step 1: Install React Router

Let’s bring in the latest version:

pnpm i -D react-router-dom@latest

🗂️ Step 2: Add Basic Pages

Inside the src/pages folder, let’s add these:

- Home.tsx
- Contact.tsx
- About.tsx
- NoPage.tsx

This gives our app the structure it needs for experiments, testing, and learning.


✍️ Step 3–4: Start Routing Setup

Inside App.tsx, first import routing tools and your shiny new pages:

import { BrowserRouter, Routes, Route } from "react-router-dom";

import LandingPage from "./pages/Landing/LandingPage";
import AboutUsPage from "./pages/About/AboutUs";
import ContactUsPage from "./pages/Contact/ContactUs";
import NotFoundPage from "./pages/NotFound/NotFound";

🧩 Step 5–7: Define Routes

Let’s connect routes to pages!

<Route path="/" element={<LandingPage />} />
<Route path="/about" element={<AboutUsPage />} />
<Route path="/contact" element={<ContactUsPage />} />
<Route path="*" element={<NotFoundPage />} />

✅ The last route acts like a catch-all. If someone types /i-am-great or any unsupported path, they’ll be shown a not-found page.


🤖 Step 8: Full Working Code (With Aioha too!)

Here’s what a complete working setup looks like:

import "./App.css";

import { initAioha } from "@aioha/aioha";
import { AiohaProvider } from "@aioha/react-ui";
import HiveUserAvatarButton from "./Components/HiveUserAvatarButton";

import { BrowserRouter, Routes, Route } from "react-router-dom";

import LandingPage from "./pages/Landing/LandingPage";
import AboutUsPage from "./pages/About/AboutUs";
import ContactUsPage from "./pages/Contact/ContactUs";
import NotFoundPage from "./pages/NotFound/NotFound";

const aioha = initAioha();

function App() {
  return (
    <AiohaProvider aioha={aioha}>
      <BrowserRouter>
        <Routes>
          <Route path="/" element={<LandingPage />} />
          <Route path="/about" element={<AboutUsPage />} />
          <Route path="/contact" element={<ContactUsPage />} />
          <Route path="*" element={<NotFoundPage />} />
        </Routes>
      </BrowserRouter>
      {/* <HiveUserAvatarButton /> */}
    </AiohaProvider>
  );
}

export default App;

🎨 Let's Add a Navbar

Now that routing works, I thought: Why not add a navigation bar?

So I visited daisyUI and saw their beautiful navbar designs.

daisyui - Let's add navbar - screenshot

I added a new component called NavBar.tsx inside the components folder, and copy-pasted their JSX template.

Copy template code from JSX tab from daisy UI

After customizing the dummy content, I expected 🪄 magic.

But instead…


💥 It Broke Everything!

😢 It was chaos. The menu looked horrible on the landing page, and nothing aligned.

cry sob - did not work as expected

So yeah… I’ll fix this navbar beast in the next post 😅


🧵 Conclusion

Originally I planned to cover both routing and navigation, but that’s now a 2-part series!

So in this post, we:

✅ Installed react-router-dom
✅ Set up page routing
✅ Got a working layout (minus the navbar 😅)

Next time, we’ll tame the navbar and wire up navigation using Link from React Router.


🙏 Thank You!

Thanks for reading, Hive friends!
Let’s keep building, breaking things, and laughing while we debug 😂

More power to the Hive Blockchain and all its lovely devs, builders & dreamers!


📝 Final Note

Since English isn’t my first language, I asked ChatGPT/AI to help optimize this post to make it more readable and viewer-friendly.

I hope this isn’t against any downvoting rules 🙏
But if it is, feel free to let me know and I’ll be more cautious next time.


🚀 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! ❤️


Sort:  

Listen closely don't keep downvoting my original content with your @letusbuyhive account tell Dan I said hello 👋🏾

Well Done Young Man.

Congratulations @sagarkothari88! You have completed the following achievement on the Hive blockchain And have been rewarded with New badge(s)

You got more than 10000 replies.
Your next target is to reach 10500 replies.

You can view your badges on your board and compare yourself to others in the Ranking
If you no longer want to receive notifications, reply to this comment with the word STOP

Check out our last posts:

Hive Power Up Day - August 1st 2025

$WINE

Thank you for the wine token @theguruasia

Have a happy weekends

via Inbox

Cheers~

$WINE


Congratulations, @theguruasia You Successfully Shared 0.100 WINEX With @sagarkothari88.
You Earned 0.100 WINEX As Curation Reward.
You Utilized 1/5 Successful Calls.
wine_logo



Contact Us : WINEX Token Discord Channel
WINEX Current Market Price : 0.031



Swap Your Hive <=> Swap.Hive With Industry Lowest Fee or Highest Reward : Click This Link
Read Latest Updates Or Contact Us

More wine. Does it work?

Here is !PIZZA for you (hopefully it'll work)

via Inbox

PIZZA!

$PIZZA slices delivered:
@sagarkothari88(5/15) tipped @theguruasia

Come get MOONed!