Customize the dashboard / welcome page

There’s an (at the moment Chrome-only) API that can be used for redirecting from /admin:

  bootstrap(app: any) {
    const url = "/admin/content-manager";

    if ("navigation" in window) {
      // Redirect soft /admin navigations to `url`
      // Chrome-only
      window.navigation.addEventListener("navigate", (e) => {
        const { pathname } = new URL(e.destination.url);

        if (new RegExp("^/admin/?$").test(pathname)) {
          window.navigation.navigate(url);
        }
      });
    }

    // Redirect hard /admin navigations to `url`
    if (new RegExp("^/admin/?$").test(location.pathname)) {
      location.href = url;
    }
  },

Also, in case you’re using TypeScript:

npm install -D @types/dom-navigation

Thanks for the idea of using bootstrap @Apostata.

2 Likes