Manage Sidebar Menus
The sidebar menu gets rendered through the JumboNavbar component and it offers a way to generate menus dynamically, even menus can be fetched and generated from a server side api call to support a secure way to provide the menu access.
API to Fetch Menus
To fetch the menus from the server, you can setup an api under the /src/api
folder. For example, in our demo, we have created an API endpoint at /src/api/menus/[locale]/route.ts
This endpoint defined in the route.ts will return an array of objects (menu items with nested children). Here is how it will look like:
Types of Menu Item
There are three types of menu items:
Section Labels
Collapsible Menu Items
Nav Item
Section Labels
A section label can be used to group multiple collapsible menu items and nav items and can be defined with only two properties as below:
Collapsible Menu Items
A collapsible menu item can be used to group multiple nav items or other collapsible menu items. The collapsible menu item can have two additional properties associated with it as below:
Nav Item
The nav item is the finally clickable item and linked with a route. So, it has additional property called path and can be defined as below:
Comparing Nav Item with Collapsible Menu Item, the Nav Item doesn't have collapsible and children property but have an additional property path instead.
Last updated