Skip to content

Fesyse/another-react-router

Repository files navigation

Another react router

npm version npm downloads img

Installation

npm install another-react-router
(bun/yarn/pnpm) add another-react-router

Getting started

Create directory where all of your routes will be located

for example:

{
  "src": {
    "routes": [
      "page.tsx"
    ]
  },
}

Create a file with name page.tsx and add the following code:

// ./src/routes/page.tsx

export default function Page() {
  return <div>Hello another react router!</div>
}

Then run our cli to initialize router

npx arr init

Create RouterProvider component for your app

for example:

// ./src/components/providers/router-provider.tsx
import { AnotherReactRouterProvider } from "another-react-router"
import { routes } from "../../../another-react-router.config.ts"

export const RouterProvider = () => (
  <AnotherReactRouterProvider routes={routes} />
)

Add RouterProvider to your app

// ./src/app.tsx
import { RouterProvider } from "@/components/providers/router-provider.tsx"

export const App = () => <RouterProvider />

Now your app is ready to go!

Documentation

See more informations on https://another-react-router.vercel.com

Changelog

See changelog in CHANGELOG.md