kibana/docs/development/core/public/kibana-plugin-public.appmountparameters.appbasepath.md
Josh Dover b352f67bdb
Add ApplicationService Mounting (#41007)
* Add core-only bundle

* Add ApplicationService mounting

* Add LegacyCore{Setup,Start}

* Fix PR comments

* Add functional tests

* Fix PR comments

* Fix PR comments

* Remove other usages of rootRoute

* Use state field notation

* Add support for open in new tab

* Fix PR comments

* Fix pesky await from the dead

* Update docs

* Bump @types/history
2019-09-03 13:03:05 -05:00

1.3 KiB

Home > kibana-plugin-public > AppMountParameters > appBasePath

AppMountParameters.appBasePath property

The base path for configuring the application's router.

Signature:

appBasePath: string;

Example

How to configure react-router with a base path:

// inside your plugin's setup function
export class MyPlugin implements Plugin {
  setup({ application }) {
    application.register({
    id: 'my-app',
    async mount(context, params) {
      const { renderApp } = await import('./application');
      return renderApp(context, params);
    },
  });
}

// application.tsx
import React from 'react';
import ReactDOM from 'react-dom';
import { BrowserRouter, Route } from 'react-router-dom';

export renderApp = (context, { appBasePath, element }) => {
  ReactDOM.render(
    // pass `appBasePath` to `basename`
    <BrowserRouter basename={appBasePath}>
      <Route path="/" exact component={HomePage} />
    </BrowserRouter>,
    element
  );

  return () => ReactDOM.unmountComponentAtNode(element);
}