Routing

Routing is 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 <Route> component included with React Router.

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

Props

name

description

‚Äč

title

page title

string

path

page url

string

layout

name of view layout component

string

render

view component with child

function

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

<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 also need to create a view and pass it to the display property of the <View> component.