Gravity
Search…
Routing
Routing is handled client-side using react-router-dom. All routes are defined in /client/src/routes and automatically generated in /client/src/app/app.js

Defining a New Route

Routes are defined in their respective file inside /client/src/routes. To add a new route, simply import View component and add a new object to the route array.
1
{
2
path: '/account/password',
3
view: Password,
4
layout: 'app',
5
permission: 'user',
6
title: 'Your Password'
7
},
Copied!
Public routes without a permission (such as the website and auth pages) are generated using the standard <Route> component included with React Router.
1
<Route exact path='/signup'
2
render={() => <View display={ Signup } layout='auth' title='Sign up' />}/>
Copied!

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.
1
<PrivateRoute exact path='/signup' permission='user'
2
render={() => <View display={ Dashboard } layout='app'
3
title='Dashboard' />}/>
Copied!
Last modified 1yr ago
Copy link