Integrating Aurelia with WordPress backend

I would like to create a WordPress plugin. The plugin adds a panel to the WordPress admin interface. This panel should host an Aurelia application.

I have successfully gotten the Aurelia application to work in WordPress.

All WordPress does at the moment is this:

function render_admin_screen() {
    echo '<my-app></my-app>';
    echo '<script type="module" src="http://localhost:9000/entry.bundle.js"></script>';

Which translates to adding the two html tags when the user clicks on the plugin name on the side menu.

Yay, this is working. It even automatically updates when changes are made to the code.

Now the next step is to add routing. The url of the page is structured like this http://localhost:8888/wp-admin/admin.php?page=PluginName.

Adding in router lite-config

    useUrlFragmentHash: true

and routes

  routes: [
    { path: '', redirectTo: 'database' },
      path: 'database',
      component: DatabaseRoute,
      title: 'Database',
      path: 'settings',
      component: SettingsRoute,
      title: 'Settings',
  fallback: 'database'

Now with routing turned on, when the au app is activated the url changes to this:

Navigating to one of the routes then changes it back to this:


Looks like everything works as expected here.

I guess another approach is to swap the my-app tag for an iframe

function render_admin_screen() {
	echo '<iframe src="http://localhost:9000/index"></iframe>'; 

Everything works as expected here.

Has anyone tried something similar? Any tips?