Routing

Page routes are handled client-side using react-router-dom. All routes are managed within /client/src/app/app.js

Public routes such as the website and auth pages use the standard component included with react-router-dom.

<Route exact path='/signup'
  render={() => <View display={ Signup } layout='auth'
 title='Sign up' />}/>

Properties

  • path - the page URL
  • layout - the page layout for the view
  • render - renders a view component with a child
  • title - the page title

Gravity also contains a custom <PrivateRoute> component that enables you to protect routes with a user permission. <PrivateRoute> accepts an optional user permission type.

<PrivateRoute exact path='/signup' permission='user'
 render={() => <View display={ Dashboard } layout='app'
 title='Dashboard' />}/>

To add a new page to your application, create a new <Route> or <PrivateRoute>. You will need to create a view and pass it to the display property.