Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sital002/react-routing

A simple and light weight routing library for react
https://github.com/sital002/react-routing

react react-routing

Last synced: 13 days ago
JSON representation

A simple and light weight routing library for react

Awesome Lists containing this project

README

        

# A simple and light weight routing library for react

```bash
npm i @sital002/react-routing
```

## How to implement it

App.jsx

```jsx
import { BrowserRouter, Route, Routes } from "@sital002/react-routing";
import Footer from "./components/Footer";
import Navbar from "./components/Navbar";
import About from "./pages/About";
import Contact from "./pages/Contact";
import Home from "./pages/Home";

function App() {
return (
<>



} />
} />
} />



>
);
}

export default App;
```

Navbar.jsx

```jsx
import { Link } from "@sital002/react-routing";

function Navbar() {
return (




  • Home



  • About



  • Contact




);
}

export default Navbar;
```

useRouter()

```jsx
import { useRouter } from "@sital002/react-routing";
import React from "react";

export default function Footer() {
const router = useRouter();
return (


{
router.push("/");
}}
>
Home

{
router.push("/about");
}}
>
About

{
router.push("/contact");
}}
>
Contact

{
router.back();
}}
>
Go back

{
router.forward();
}}
>
Go forward


);
}
```