React Native Router v4.x
The first declarative React Native router.
Define all your routes in one React component...
...and navigate from scene to scene with a simple, powerful API
Try the example app
v4 Features
- Based on latest React Navigation API
- Separate navigation logic from presentation. You may change now navigation state directly from your business logic code - stores/reducers/etc. navigationStore
- Built-in state machine (v3
Switch
replacement)- Each
Scene
withcomponent
defined can haveonEnter
/onExit
/on
handlers. onEnter
/on
handler can be async.- For 'truthy' return of
onEnter
/on
,success
handler (if defined) will be executed- if
success
is a string then router will navigate to theScene
with that key
- if
- in case of handler's failure,
failure
prop (if defined) will be run. - Combining
onEnter
,onExit
,success
, andfailure
makes patterns like authentication, data validation, and conditional transitions simple and intuitive.
- Each
- MobX-friendly: all scenes are wrapped with
observer
. You may subscribe tonavigationStore
(Actions
in v3) and observe current navigation state. Not applicable to Redux. - Flexible nav bar customization not currently allowed by React Navigation:
https://github.com/react-community/react-navigation/issues/779 - Drawer support (provided by React Navigation)
- Inheritance of scene attributes allow you to avoid any code/attribute duplications. Adding
rightTitle
to a scene will apply to all child scenes. See example app. - Access to your app navigations state as simple as
Actions.state
. - Use
Actions.currentScene
to get name of current scene.