Docs
API Reference
Components
RouterComponent

RouterComponent

RouterComponent is a class provided by Rasengan.js used to create Routers in your application.

Learn what Routers are here.

Usage

app.router.tsx
import { RouterComponent, defineRouter } from "rasengan";
 
class AppRouter extends RouterComponent {};
 
export default defineRouter({
  imports: [], // Import others routers
  layout: null, // Set a layout
  pages: [] // Import pages
})(AppRouter)

Properties

Here is the list of all the properties of RouterComponent class.

PropertiesTypeDescription
routersRouterComponent[]An array of other Router classes to be imported.
layoutLayoutComponentThe layout component to be used.
pagesPageComponent[]An array of page components to be used.
notFoundComponentReact.FCThe 404 page component to be used.
loaderComponentReact.FCThe loader component to be used.

Rather than setting these values manually, the defineRouter does it for us and create a new instance of RouterComponent class and return it.

Logo Image