Rocon Website

Exact Route

At the previous page we learned how to render contents in response to URLs like /foo or /bar. Then, how do we handle the root path (/)?

In this case, we use another method named exact as in the next example.

const toplevelRoutes = Rocon.Path()
  .exact({
    action: () => <p>I am top page</p>
  })
  .route("foo", (route) => route.action(() => <p>This is foo</p>))
  .route("bar", (route) => route.action(() => <p>This is bar</p>));

To register the action of the root path, we pass an object containing an action property to the exact method. Order does not matter; both exact and route can come first.