Docs
Installation
Installation
How to integrate another react router with your project
Install package
npm install another-react-router
Create directory where all routes will contain
Open page.tsx
file and paste example code
export default function Page() {
return <div>Hello another react router!</div>
}
Run CLI
npx another-react-router init
By default it will create another-react-router.config.ts
at the same level as src
folder
See cli docs for more information
Add router provider component
import { AnotherReactRouterProvider } from "another-react-router"
import { routes } from "another-react-router.config.ts"
export function App() {
return <AnotherReactRouterProvider routes={routes} />
}
To import routes
from another-react-router.config.ts you need to change your tsconfig.json
{
// ... other options ...
"compilerOptions": {
// ... compiler options ...
"paths": {
"baseUrl": ".",
"another-react-router.config.ts": ["another-react-router.config.ts"]
}
}
}
Or if you are using vite you need to change 2 files which is tsconfig.json
and tsconfig.app.json
and past code above
That's it
Now you can start your project and go to localhost:3000
and see that router is working perfectly!