Skip to content

Router [frontend]

Andrej T edited this page Mar 9, 2019 · 1 revision

The router in H4BFF is based on Mobx and React.

It has an imperative API (not declarative) so that plugins can add their own routes, without having to define all routes in a single file.

Here's an example app:

import { AppContainer } from '@h4bff/core';
import { Router } from '@h4bff/frontend';

let app = new AppContainer();

function myPlugin(app: AppContainer) {
  let router = app.getSingleton(Router);
  router.addRoute('/cars', () => <div>My cars page</div>)
  router.addRedirect('/', '/cars')
}

myPlugin(app);

Handling 404

TBD.

Clone this wiki locally