<RouterNavigator />

This component is a variant of the Navigator with a declarative API. In order to manage to display the pages, the navigator needs to define the renderPage method, that takes an route and a navigator and converts it to an page.


Stack navigation

The Navigator is a component that provides stack based navigation. It is a very common navigation pattern in mobile apps.

After pushing a page to the top of the stack it will be displayed using transition animation. When the user goes back to the previous page the top page will be popped from the top of the stack and hidden with an corresponding transition animation.

Basic usage

The Navigator maintains a stack of route objects. These objects can be arbitrary objects and are rendered into pages with the renderPage property. The renderPage property must be set to a function that returns a Page component.

To push a new page on top of the stack, the pushPage(route) method is used. Similarly, a page is popped from the stack with the popPage() method.

The stack must be initialized with either the initialRoute or initialRouteStack, depending on whether the the stack needs to be initialized with one or more pages.

The back button

The BackButton component can be used to put a back button in the navigation bar. The component will automatically find the Navigator component and pop a page when pressed.

  <div className='left'>
  <div className='center'>

Customizing the animation

There are several animations available for the Navigator component. To change the animation the animation property is used. Available animations are slide, lift and fade. Setting the property to none will make the transition instantly.

It is also possible to customize the duration, delay and timing function of the animation using the animationOptions property.

  animationOptions={{duration: 0.2, timing: 'ease-in'}}

For iOS’ “swipe to pop” feature, add the swipeable prop. Note that this behavior is automatically removed on Android platforms unless swipeable={'force'} is specified.


Name Type Description
renderPage function This function takes the current route object as a parameter and returns a react componen. Required.
routeConfig object

This object must contain two properties: routeStack: An array of route objects, processStack: An array of process objects { type: push | pop | reset, route: userRoute } that describe the transition from the current state to the next state. Make sure that the route stack is not emptied before the animations for the processStack have completed. It is recommended to update the routeStack and empty the processStack in the ‘onPostPop’ callback.

onPrePush function Called just before a page is pushed. Optional.
onPostPush function Called just after a page is pushed. Optional.
onPrePop function Called just before a page is popped. Optional.
onPostPop function Called just after a page is popped. Optional.

Animation name. Available animations are "slide", "lift", "fade" and "none". These are platform based animations. For fixed animations, add "-ios" or "-md" suffix to the animation name. E.g. "lift-ios", "lift-md". Defaults values are "slide-ios" and "fade-md".

animationOptions object Specify the animation’s duration, delay and timing. E.g. {duration: 0.2, delay: 0.4, timing: 'ease-in'}. Optional.
swipeable bool Enables swipe-to-pop functionality for iOS. Optional.
swipePop function Function called on swipe-to-pop. Must perform a popPage with the given options object. Optional.
onDeviceBackButton function Custom handler for device back button. Optional.

Need Help?

If you have any questions, use our Community Forum or talk to us on Discord chat. The Onsen UI team and your peers in the community will work together to help solve your issues.

For bug reports and feature requests use our GitHub Issues page.